#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2013
    Posts
    1
    Rep Power
    0

    While loop stops


    Hi, I have been looking around and haven't found a solution to a problem I have with a while loop.

    The issue:
    When a while loop has more than 30000 repeats it simply stops. There is no obvious memory shortage. I checked that with "memory_get_usage(true)". So I thought the execution time was to long and put "set_time_limit(0)" in my script. Unfortunately no effect. Anyone who has encountered this issue? Thanks in advance for your response.

    This is the script:

    PHP Code:
    function toInteger($string){ 
       
    sscanf ($string'%u%c'$number$suffix);
       if (isset (
    $suffix)) { 
          
    $number $number pow (1024strpos (' KMG'$suffix)); 
       } return 
    $number


    ignore_user_abort(false); 
    $a 1
    echo 
    "max: " toInteger(ini_get('memory_limit')) . "<p/>"$oneStepMemoryUsage memory_get_usage(true); $enoughMemory true

    while(
    $enoughMemory) { 
       
    set_time_limit(0); 
       if(
    $a == 1) { 
          
    $oneStepMemoryUsage memory_get_usage(true) - $oneStepMemoryUsage
       } 
       if(
    $a 100000) { 
          
    $enoughMemory false
       } else { 
          
    $ids = array(); 
          
    $ids['id'] = $a
          
    $view->addRow($ids, array("memory_get_peak_usage(): " memory_get_peak_usage() . " - memory_get_usage(true): " memory_get_usage(true))); $a++; 
       } 


    $view->draw(); 
    UPDATE: I was able to log to a textfile until memory ran out. Apparently this operation can easily pass the 30K repeats.
    Last edited by MartinVille; April 11th, 2013 at 07:14 AM. Reason: Code not properly formatted

IMN logo majestic logo threadwatch logo seochat tools logo