i’m building a php server, and i’m logging each command the server is doing.
inside my log i’ve a added a column that shows on each log what was the memory in use in this step using the memory_get_usage(true) function.
from some reason it always shows me 256 (i’ve divided the function in / 1024 to get it in KB), although i’m connection to an sql server, adding new instance of objects, running loops etc..
why is that ?
this is my log code:
function serverLog($status, $message)
{
global $logFile, $currentTime;
$log = "\n" . date("d/m/Y", $currentTime) . "|" . date("H:i:s", $currentTime). "|" . $status . "|" . $message . "|" . (memory_get_usage(true) / 1024);
$fp = fopen($logFile, "a+") or die ("can't open file");
fwrite($fp, utf8_encode($log));
fclose($fp);
}
memory_get_usage(true)shows the amount of memory allocated by the PHP engine, which only changes if your script requires more memory.