Created
June 30, 2012 20:31
-
-
Save schmittjoh/3025399 to your computer and use it in GitHub Desktop.
PHP Memory Limit 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 | |
// Memory Limit: -1 | |
// Max Execution Time: 0 | |
printf("Memory Limit: %s\n", ini_get('memory_limit')); | |
printf("Max Execution Time: %s\n", ini_get('max_execution_time')); | |
// Fatal error: Out of memory (allocated 1913651200) (tried to allocate 536870912 bytes) | |
// 1825,00 MB | |
$a = array(); | |
while (true) { | |
$a[] = new stdClass; | |
} | |
// Fatal error: Out of memory (allocated 1812725760) (tried to allocate 134217728 bytes) | |
// 1728,75 MB | |
$i = 1; | |
while ($i++) { | |
${'a'.$i} = 'a'; | |
} | |
// Fatal error: Out of memory (allocated 1678508032) (tried to allocate 134217728 bytes) | |
// 1600,75 MB | |
$a = array(); | |
while (true) { | |
$a[] = 'a'; | |
} | |
// Fatal error: Out of memory (allocated 477364224) (tried to allocate 476839913 bytes) | |
// 455,25 MB | |
$a = ''; | |
while (true) { | |
$a .= 'a'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment