Last active
March 1, 2019 08:04
-
-
Save nurullahisik/76310b3ea08ec59feef72d2dc604ff90 to your computer and use it in GitHub Desktop.
PHP Memory Test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Foo | |
{ | |
public $var = '3.14159265359'; | |
} | |
$baseMemory = memory_get_usage(); | |
for ( $i = 0; $i <= 100000; $i++ ) | |
{ | |
$a = new Foo; | |
$a->self = $a; | |
if ( $i % 500 === 0 ) | |
{ | |
echo sprintf( '%8d: ', $i ), memory_get_usage() - $baseMemory, "\n"; | |
} | |
} | |
echo "Peak: ".memory_get_peak_usage()." bytes \n"; | |
/* prints | |
Peak: 13687072 bytes | |
*/ | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment