get system free memory in php

To get the amount of free memory available on the system in PHP, you can use the memory_get_usage() function. This function returns the amount of memory used by PHP at the moment of its call.

main.php
$freeMemory = memory_get_usage(true);
38 chars
2 lines

The parameter true instructs the function to return the amount of free memory available to PHP.

Note that this value represents the amount of memory that PHP can use, but not necessarily the total amount of free memory on the system.

related categories

gistlibby LogSnag