0

我正在尝试使用 ujson.loads 加载一个 2GB 的 json 文件,并出现内存错误:

  File "dict.py", line 70, in <module>
    dct = load_dict_file()
  File "dict_load.py", line 25, in load_latest_dict
    dct = ujson.loads(dict_txt)
MemoryError

我正在使用 Python 3.7 在具有足够可用内存的 EC2 机器(Linux)上运行我的代码:

[ec2-user@ip]$ free -m
              total        used        free      shared  buff/cache   available
Mem:          15463         269       14330          11         863       14911
Swap:             0           0           0

代码在我的本地机器(Windows)上按预期运行,所以不确定是什么导致了内存错误。我考虑过使用 ijson,但它看起来不适合我的用例(使用 sqlalchemy 会话将 json 文件逐键加载到表中的行)。

谢谢

4

0 回答 0