×

Welcome to TagMyCode

Please login or create account to add a snippet.
0
0
 
0
Language: PHP
Posted by: bejoy balan
Added: Jul 6, 2017 10:53 AM
Views: 10
Tags: test memory
  1. function tryAlloc($megabyte){
  2.     //  echo "try allocating {$megabyte} megabyte...";
  3.     $dummy = str_repeat("-",1048576*$megabyte);
  4.     // echo "pass.";
  5.     //echo "Usage: " . memory_get_usage(true)/1048576;
  6.     // echo " Peak: " . memory_get_peak_usage(true)/1048576;
  7.     // echo "\n";
  8. }
  9. for($i=10;$i<1000;$i+=50){
  10.     $limit = $i.'M';
  11.     //   sleep(1);
  12.     //ini_set('memory_limit', $limit);
  13.     //  echo "set memory_limit to {$limit}\n";
  14.     //  echo "memory limit is ". ini_get("memory_limit")."\n";
  15.     tryAlloc($i-10);
  16. }