Re: Any way to stop PHP taking >30 mb of RAM?
| From: | Matthew Brealey | Date: | Wed, 15 Nov 2000 10:47:23 +0000 |
| Subject: | Re: Any way to stop PHP taking >30 mb of RAM? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-25408@lists.php.net to get a copy of this message | ||
You wrote:
> > I have a script that generates several hundred HTML pages. Each page
> > has a navigation table (which requires recursive calls to read database
> > files), which initially I built for each page. This caused PHP to take
> > over the machine - I couldn't stop it, couldn't move the mouse, etc.
> > Eventually after leaving it thrashing the disk overnight I turned it
> > off. Fortunately although e2fsck failed the first time, I was able to
> > get my machine back.
> >
> > I optimized my script by building the navigation tables only 25 instead
> > of 400 times, and then using regexps with back references on these
> > tables. It now completes. However, it takes so much memory (between 29
> > and 35mb (this is the total (my Apache uses mm under Linux with PHP 4
> > as a DSO)- not the sum of threads which some people get misled by) I
> > have to kill and restart httpd every time I run it - otherwise my
> > (64mb) machine becomes unusable.
>
> Optimize your script some more? I don't quite understand what you are
> doing, but it probably should not be that tricky to change the recursion
> into iteration, and that right there will save you buttloads of CPU time and
> RAM.
Have done.
> Figure out where all that processing time is going, and find another way to
> do it.
It's reading 400 pages and building HTML from them - this is 95% of the
processing time.
But really what I was concerned about was that PHP just gobbled up my
RAM and didn't give it back - I wouldn't mind machine being unable to
cope for a short period so long as it gives me my RAM back afterwards.
-- Random fortune
I want a WESSON OIL lease!!