我有两个JSON文件(一个大约40 mb,第二个大约30 mb)。我把它们包括在内:
$one= json_decode(file_get_contents('../../trigrams.json'), true);
$two= json_decode(file_get_contents('../../fourgrams.json'), true);
默认我得到:
Allowed memory size of 134217728 bytes exhausted (tried to allocate 44 bytes)
我试过
ini_set('memory_limit', '1024M');
结果是
Allowed memory size of 1073741824 bytes exhausted (tried to allocate 3 bytes)
有人可以解释这些数字吗?为什么我需要这么多记忆?
编辑:标记的副本并没有解决问题,因为它没有解释为什么内存使用对于这种相对较小的数据而言如此之高。
EDIT2:设置
时错误消失ini_set('memory_limit', '2048M');
但这不是理想的解决方案。