I have a script, that gets data send (about 16MB in size), which I read using php://input
.
$in = file_get_contents("php://input");
But I'm running into memory limit issues, so I traced it down using memory_get_usage()
and realized, that the script is already consuming 47MB memory on startup (before issuing any command).
My guess is, this is due to PHP pre-filing global variables. So I'm searching for a way to unset those, since I'm only reading the php://input stream.
I tried:
unset($GLOBALS);
unset($_SERVER);
unset($_GET);
unset($_POST);
unset($_FILES);
unset($_REQUEST);
unset($_ENV);
unset($_COOKIE);
unset($HTTP_RAW_POST_DATA);
unset($http_response_header);
unset($argc);
unset($argv);
gc_collect_cycles();
And it reduces the memory usage from 47MB to 31MB.
Is there anything else I can do, to have PHP consume less memory on startup?
It would give me more memory to work with the data I received.