Why do I need a memory limit above 1024 M for 70 MB JSON

I have two JSON files (about 40 mb and the second ~ 30 mb). I turn them on like this:

$one= json_decode(file_get_contents('../../trigrams.json'), true);
$two= json_decode(file_get_contents('../../fourgrams.json'), true);

By default, I get:

Allowed memory size of 134217728 bytes exhausted (tried to allocate 44 bytes)

I tried

ini_set('memory_limit', '1024M');

The result is

Allowed memory size of 1073741824 bytes exhausted (tried to allocate 3 bytes)

Can someone explain these numbers? Why do I need so much memory?

EDIT: The noted duplicate does not solve the problem as it does not explain why memory usage is so high for such a relatively small amount of data.

EDIT2: Installation Error

ini_set('memory_limit', '2048M');

But this is not a solution.

+4
source share

Source: https://habr.com/ru/post/1625836/


All Articles