fork download
  1. <?php
  2.  
  3. define ( 'K', 1024 );
  4. define ( 'M', K * K );
  5.  
  6. define ( 'COUNT_MAX' , 10 * M );
  7. define ( 'PRINT_STEP', 100 * K );
  8.  
  9. $memory_base = memory_get_usage();
  10.  
  11. $a = array();
  12.  
  13. for ( $n = 0; $n <= COUNT_MAX; ++$n ) {
  14. if($n % PRINT_STEP === 0)
  15. echo $n . "\t" . (memory_get_usage() - $memory_base) / M . "\n";
  16. $a[$n] = $n;
  17. }
  18.  
  19. ?>
  20.  
Runtime error #stdin #stdout 1.62s 13112KB
stdin
Standard input is empty
stdout
0	0.000312805175781
102400	7.1411857605
204800	14.2820854187
307200	21.9229736328
409600	28.563873291
512000	35.2047729492
614400	43.8456611633
716800	50.4865608215
819200	57.1274528503
921600	63.7683525085
1024000	70.4092445374
1126400	81.0501441956
1228800	87.6910324097
1331200	94.3319320679
1433600	100.972831726
1536000	107.613723755
1638400	114.254623413
1740800	120.895511627
1843200	127.536411285

Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes) in /home/WKXbN8/prog.php on line 16