Код:
<?php
$url = 'https://api.sputnik8.com/v1/products?api_key=9bc84ec26f47bf3005dc55434b4b796a&username=partners+tpo50@sputnik8.com';
$data = json_decode(file_get_contents($url), true);
var_dump(MemoryUsage());
function MemoryUsage(): string
{
$size = memory_get_usage();
$unit = ['b', 'kb', 'mb', 'gb', 'tb', 'pb'];
return round($size / pow(1024, ($i = floor(log($size, 1024)))), 2) . ' ' . $unit[$i];
}
Результат:
devilbox@php-8.1.14 in /shared/httpd $ time php large-json.php
/shared/httpd/large-json.php:6:
string(7) "31.7 mb"
real 0m6.331s
user 0m0.110s
sys 0m0.086s
Потребляет всего 32 мегабайта.
Проблема то в чём?