Skip to content

Instantly share code, notes, and snippets.

@mikeschinkel
Created March 31, 2013 20:15
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 mikeschinkel/183b4b33a65d6880b924 to your computer and use it in GitHub Desktop.
Save mikeschinkel/183b4b33a65d6880b924 to your computer and use it in GitHub Desktop.
Example code to see how much memory a small class consumes.
echo "<br>";
echo memory_get_usage();
class Foobar {
var $a = 'abcdefghijklmnopqrstuvwxyz';
var $b = 1000;
var $c = false;
var $d;
function __construct() {
$this->d = array(
'a' => $this->a,
'b' => $this->b,
'c' => $this->c,
);
}
}
$fb= new Foobar();
echo "<br>";
echo memory_get_usage();
class Foobar1 {
}
echo "<br>";
echo memory_get_usage();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment