Skip to content

Instantly share code, notes, and snippets.

@willvincent
Created April 9, 2015 20:16
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 willvincent/55bf1e7baeecec564a89 to your computer and use it in GitHub Desktop.
Save willvincent/55bf1e7baeecec564a89 to your computer and use it in GitHub Desktop.
Spits out approximate memory usage of an app (passed as an argument) -- mac os 10.9+ (maybe earlier)
<?php
$app = $argv[1];
print exec('hostinfo | grep memory | perl -ne \'$used = `ps aux | grep ' .
$app . ' | awk \'"\'"\'{x+=\$4} END{print x/100}\'"\'"\'` and /Primary memory available: (\d+)/ and printf("' .
$app . ' is using approximately ") and printf($1*$used) and print ("GB\n");\'');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment