Skip to content

Instantly share code, notes, and snippets.

@miteshmap
Created February 6, 2019 17:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miteshmap/0f780d41022a5f7f2df1f3c5496fda04 to your computer and use it in GitHub Desktop.
Save miteshmap/0f780d41022a5f7f2df1f3c5496fda04 to your computer and use it in GitHub Desktop.
Check memory used by a script.
<?php
// Add these lines at the end of your code.
echo PHP_EOL;
echo "Memory Usage :" . memory_get_usage();
echo PHP_EOL;
echo "Real Memory Usage :" . memory_get_usage(true);
echo PHP_EOL;
echo "Real Peak Memory Usage :" . memory_get_peak_usage(true);
echo PHP_EOL;
echo "Peak Memory Usage :" . memory_get_peak_usage();
echo PHP_EOL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment