Re: PHP memory garbage collection



Anze wrote:
Anybody? Please? I really need to solve this...

Is there a way to measure current memory consumption?

Regards,

Anze

Anze wrote:

Hi!

I have a script that uses a lot of memory and an ISP that has memory-limit
set to 10 Mb. The script of course doesn't finish running. :(

The program is rather simple - it parses XML into an array and then starts
the loop that inserts data into the database. If I use a very large XML
file then the PHP crashes inside the loop (Fatal error: Allowed memory
size of 10485760 bytes exhausted) - indicating that the problem lies
within loop somewhere.

Can I trace memory consumption of a PHP script so I can determine where
the memory is wasted?

If PHP uses all the memory (and frees nothing) until the end of the script
then that could be the problem - is there any way I can force it to do
garbage collection?

Any comment on how PHP uses memory would be appreciated - I would really
hate to have to break the script into smaller pieces (or change ISP for
that matter :) ).

Thanks!

Anze


I'm already thinking of a solution, my fault...

Look into your script for where you have global variables which you don't need anymore and then unset them (unset($var)).

If you can't solve it this way, you can contact your ISP to run the script for you through SSH or something.

I don't think you would run the script often or do you? If you do, I suggest thinking about the logic and effeciency about your piece of programming.
.




Relevant Pages

  • Re: script dies yet there are no errors in error log
    ... This script dies after processing about 20 or 25 ... maybe 7 per UPC code. ... a little memory in PHP - but also results in a call to MySQL to free ... realized the whole, long, complicated whileloop could be rewritten ...
    (comp.lang.php)
  • Re: environment variable
    ... Each site would have script that they would run to get the addresses for ... I have a "FOR" loop runing. ... doing a call to set the variable in volitle memory and using that variable ... >> The problem experiencing is I can not seem to do the same in vbscript. ...
    (microsoft.public.scripting.vbscript)
  • Re: Possible memory leak using $sth->{NAME} ?
    ... > routine seems to leak 1 SV per execution. ... > to be a fairly insignificant amount of memory. ... > of memory per trip through the loop. ... > version of the script where the loop executes once, ...
    (perl.dbi.users)
  • Re: Incude statement - is there such a thing?
    ... I can't imagine any memory usage issues. ... And it that WSF references ... other script files (as the Docs often suggest to be ... > you had 50 statements that you wanted to execute 1000 times in a loop. ...
    (microsoft.public.scripting.vbscript)
  • Re: Incude statement - is there such a thing?
    ... but have you noticed that you get poorer compile time messages when ... > if they are constantly loaded into memory or per script. ... you had 50 statements that you wanted to execute 1000 times in a loop. ...
    (microsoft.public.scripting.vbscript)