Cross-Platform, PHP

Calculate PHP script memory usage

If you would like to know how much memory one of your PHP scripts uses when it runs, there’s a built-in function in PHP called memory_get_usage, which will display the amount of memory, in bytes, that’s being used by your PHP script.

 

1
2
3
4
5
6
7
8
 
echo 'Memory usage: '.memory_get_usage() . ' bytes.<br>';
 
// --------------------------------------
// your code goes here
// --------------------------------------
 
echo 'Memory usage: '.memory_get_usage() . ' bytes.<br>';