I just noticed – by calling memory_get_peak_usage() on an ’empty’ php file, using php-fastcgi and NGINX, the result is ~120KB of memory
<?php
print_r(memory_get_peak_usage());
?>
Does PHP really need that ‘much’ memory for every call, or does that only happen for the first call (initializing something I guess) and then every consecutive call needs less Memory?
I’m asking, because I’m kind of surprised that an empty file already uses up 140KB – guessing that a couple of classes, functions and arrays will push that number up quite fast.
And yeah, I know that this probably counts as premature optimization, but I’m really curious about knowing where those 120KB are coming from, and if there’s a way to minify that cost per call.
The first comment on the php.net docs page states:
http://php.net/manual/en/function.memory-get-peak-usage.php
And the default allotment per connection is between 8-16mb, so you’re still way below that.
For what it’s worth, doing the same thing on my server yields 650kb, so you’re already doing better than me 😉