Skip to content

Instantly share code, notes, and snippets.

@schmittjoh
Created June 30, 2012 20:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save schmittjoh/3025399 to your computer and use it in GitHub Desktop.
Save schmittjoh/3025399 to your computer and use it in GitHub Desktop.
PHP Memory Limit Test
<?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