小编lon*_*aft的帖子

Python内存没有在linux上发布?

我正在尝试将大型json对象加载到内存中,然后对数据执行一些操作.但是,我注意到在读取json文件后RAM大幅增加 - 即使对象超出范围.

这是代码

import json
import objgraph
import gc
from memory_profiler import profile
@profile
def open_stuff():
    with open("bigjson.json", 'r') as jsonfile:
        d= jsonfile.read()
        jsonobj = json.loads(d)
        objgraph.show_most_common_types()
        del jsonobj
        del d
    print ('d')
    gc.collect()

open_stuff()
Run Code Online (Sandbox Code Playgroud)

我尝试在Windows中使用Python版本2.7.12和Debian 9在Python版本2.7.13中运行此脚本,我发现Linux中的Python存在问题.

在Windows中,当我运行脚本时,它会在读取json对象时占用大量RAM,并且在范围内(如预期的那样),但是在操作完成后(如预期的那样)释放它.

list                       3039184
dict                       413840
function                   2200
wrapper_descriptor         1199
builtin_function_or_method 819
method_descriptor          651
tuple                      617
weakref                    554
getset_descriptor          362
member_descriptor          250
d
Filename: testjson.py

Line #    Mem usage    Increment   Line Contents
================================================
     5     16.9 MiB     16.9 MiB   @profile
     6                             def open_stuff():
     7 …
Run Code Online (Sandbox Code Playgroud)

python linux memory-leaks

10
推荐指数
2
解决办法
995
查看次数

ESLint - 不修改文件

我正在尝试使用ESLint来修改和修复我的代码.当我使用我的配置文件运行ESLint并且没有修复标志时,它运行正常,这就是它输出的内容.

eslint -c .eslintrc.json ./src/aura/SearchAvailableNumbers

/home/jason/sfa/testproj/src/aura/SearchAvailableNumbers/SearchAvailableNumbersController.js
    8:9   error  Unexpected blank line after variable declarations  newline-after-var
   15:13  error  'hlp' is defined but never used                    no-unused-vars
   50:30  error  'helper' is defined but never used                 no-unused-vars
   55:32  error  'helper' is defined but never used                 no-unused-vars
   59:42  error  'helper' is defined but never used                 no-unused-vars
   69:7   error  Expected { after 'if' condition                    curly
   69:22  error  Expected '===' and instead saw '=='                eqeqeq
   71:22  error  Expected '===' and instead saw '=='                eqeqeq
   76:22  error  Expected …
Run Code Online (Sandbox Code Playgroud)

javascript lint eslint

9
推荐指数
1
解决办法
2万
查看次数

如何加密表单数据?

我有一个登录表单,它将向php文件提交id和密码,然后将检查该id和pw是否与SQL数据库中的数据相对应.如何加密传出的表单数据,以确保没有人能够看到它直到它到达目的地?登录表单代码是

<html>
<head>
<title>
Login page
</title>
</head>
<body>
<form name="login" action="fetchalldata.php" method="post">
Username : <input type="text" name="userid"/>
Password : <input type="password" name="pswrd"/>
<input type="button" name="submit" value="Login"/>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)

会在数据库上预先设置密码并发送散列密码更有效吗?

html php forms encryption passwords

3
推荐指数
1
解决办法
1万
查看次数

是否可以在SQL表中包含SQL表?(用于动态生成的表单)

我有一个动态生成组中元素的表单,所以每次有人提交表单时我都无法确定要向数据库提交多少内容.

Form
  -name
  -age
  -incident (0)
  -incident description (0)
  -incident (1)
  -incident description (1)
  -incident (2....)
  -incident descritpion (2....)
Run Code Online (Sandbox Code Playgroud)

并且有大约10个可能的动态生成的表单元素组,所以我想我会为整个表单创建一个表,并且每个表依次为动态生成的元素组创建一个表.

formdata
name varchar(30)
age int(2)
incident0 sql
incdient1 sql
Run Code Online (Sandbox Code Playgroud)

那可能吗?或者除了在我的表中创建一大堆我很少使用的列之外还有不同的方式吗?如果我创建了一大堆列会有内存浪费,或者如果这些列中没有提交大量数据会不会产生影响?

php sql database database-design normalization

1
推荐指数
1
解决办法
109
查看次数