Skip to content

Instantly share code, notes, and snippets.

@KennFatt
Last active August 30, 2018 11:39
Show Gist options
  • Save KennFatt/7d61b0c2f01d75f3f6efbd8e1c50d2a6 to your computer and use it in GitHub Desktop.
Save KennFatt/7d61b0c2f01d75f3f6efbd8e1c50d2a6 to your computer and use it in GitHub Desktop.
Testing PHP's Zend Memory Manager
<?php
/**
* Testing Zend Memory Manager.
*
* Testing allocated segments in Kilobytes
*/
$m = (float) (memory_get_usage(true) / 1024);
echo "[0] Memory usage: " . $m . " Kb" . PHP_EOL;
$mem = range(1, 1024 * 1024);
$m = (float) (memory_get_usage(true) / 1024);
echo "[1] Memory usage: " . $m . " Kb" . PHP_EOL;
unset($mem);
$m = (float) (memory_get_usage(true) / 1024);
echo "[2] Memory usage: " . $m . " Kb" . PHP_EOL;
@KennFatt
Copy link
Author

KennFatt commented Aug 30, 2018

Output:

[0] Memory usage: 2048kB
[1] Memory usage: 28672kB
[2] Memory usage: 2048kB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment