WordPress Code Snippets

A fresh mix of code snippets and tutorials

PHP Get Memory Usage vs. Total


Here is a useful function that I modified for my WordPress plugin, Dashboard Widgets Suite. It returns an array containing the current memory usage and the total memory usage, so you can get and display a ratio of the values as needed.

This function returns an array with both values, memory used and total memory. Here is an example of usage:

list($mem_total, $mem_used) = shapeSpace_memory_usage();
echo $mem_total . ' / ' . $mem_used;

..which outputs something like:

3.25 MB / 2.9 MB


Show Support

Like our new Facebook Page to show support!