I am working a data and calculation intensive applications that deals with hundred of thousands of data records. I notice that if do too many calculation, my php scripts will suddenly exit in the middle of its execurtion without without erroring out. I am thinking that it is memory problem like run time stack prob in C. Does anyone have any experiences with this??

Khoa nguyen

    Your script probably thinks it's timing out nicely. I've had that, bit annoying because you can't tell that it's stalled.

    Can you break your calculations down, hold the results in a session and use meta refresh or headers to bounce to a new page and restart the calculations at regular intervals?

      The problem is not exec. timeout. I have all error_report turn on and if I get any execution timeout, it would exit and PHP would print an exec. timeout error. That did not happened. Beside, the script ran for less than 10 secs and died. I had exec. timeout = 30 sec.

      suppose you have this cript
      <?php
      $array = array();
      for($i=0; $i<1000000; $i++)
      push_array($
      array, $i);
      ?>

      My server would died within 8 secs. While running this script on another server, it would error out a timeout message.

      What do you think?

      Khoa Nguyen

        Works fine for me although i used array_push()
        which i assume you mean't, not your own function.

        it took 7 seconds on my slow work station via apache and 5 seconds via command line execution.

        increasing to 2000000 works fine just takes double the time.

        mandrake 9.0 duron 750mhz 384mb ram

          hm.... running the above script on a different system get me this error.

          Error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 524288 bytes)

          Have any one seen this??

            by increasing the memory size allocating to the script, I was able to allocate larger array.

            My project is suppose to work with any system with default configuration. Does any one know how to computer large data set without allocating more mem to the script?

            By the way, johnnyv, how much mem did you allocate to your php/apache??

            Khoa Nguyen

              Ahhh I allocated more memory in my php.ini file, i always do. You just need to do the same.

              ;;;;;;;;;;;;;;;;;;;
              ; Resource Limits ;
              ;;;;;;;;;;;;;;;;;;;

              max_execution_time = 60 ; Maximum execution time of each script, in seconds
              memory_limit = 32M ; Maximum amount of memory a script may consume (8M😎

              normally 30 secs and 8 megs.

              For your example script 16 megs will be plenty.

                hm... unfortunately I do no have access to the server at my work place. So I have to do large computation within 8M limit.

                Khoa Nguyen

                  Write a Reply...