Hi, As shown at : http://php.net/manual/en/function.memory-get-usage.php I ran this script on my site : <?php // This is only an example, the numbers below will // differ depending on your system echo memory_get_usage() . "\n"; // 36640 $a = str_repeat("Hello", 4242); echo memory_get_usage() . "\n"; // 57960 unset($a); echo memory_get_usage() . "\n"; // 36744 ?> Code (markup): and the result is : 319400 340776 319480 Compared to the example on the PHP site, memory usage for the script on my site is very high? why is this so ? Is there anything I should do to reduce memory usage? Please reply if you would like to know more info. Thank you
There's too many factors to answer this. If php is running via apache which is fairly common, it would be expected to have much higher memory usage than if it is running as cgi. Also, if you have a ton of php modules compiled with php, the memory usage would be much higher by default.
I've never had mine that high before. There must be something running that you are not aware of, or leaking or who knows what's happening on your site. If you have root access, try to restart your server and see if it makes a difference. Try also to upgrade your PHP to the latest, if you have not done.
maybe you can check the settings of your php ini, maybe your server's memory_limit is different from what the example stated. jestep has a point, your server might have more modules loaded that's why you have a higher memory usage
On one of my production servers: 50968 72320 51096 On localhost (a bigger machine, with more RAM): 322976 344280 322976 Same server/PHP installation on both. I wouldn't lose any sleep over it.