Get Memory Usage For A PHP Script
<p><br><br>
Need advise here. Currently I am get the memory usage of the script by using this code<br> </p>

<pre><code>$sysMem = escapeshellcmd(system('echo $(free)'));
memory_get_usage();
</code></pre>

<p>This is the result i am getting : </p>

<p>Total Mem : 1034708<br>
Used Mem : 1014572<br>
Free Mem : 20136<br>
Shared Mem : 0<br>
Buff Mem : 73456<br>
Cached Mem : 480752<br>
----------------------------------------------------<br>
Mem Usegae : 509464<br><br>
Total Mem : 1034708<br>
Used Mem : 1014564<br>
Free Mem : 20144<br>
Shared Mem : 0<br>
Buff Mem : 73456<br>
Cached Mem : 480828<br>
----------------------------------------------------<br>
Mem Usegae : 343904<br><br></p>

<p>However i found out that the memory usage is kind of inconsistent and at time the memory usage might even exceed the total memory which is impossible.<br><br></p>

<p>Is memory_get_usage(); the best option to get the memory usage of the php script?
Or is it i need to use unset() function. However even if i use the memory still about the same<br><br></p>

<p>if there are other methods please kindly advise.</p>

<p>Thanks a millions<br>
Guys and Ladies  </p>
