Re: Any way to stop PHP taking >30 mb of RAM?

From: Date: Tue, 14 Nov 2000 21:51:07 +0000
Subject: Re: Any way to stop PHP taking >30 mb of RAM?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-25280@lists.php.net to get a copy of this message
> 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. Figure out where all that processing time is going, and find another way to do it. > Is there anything I can do to avoid this (particularly in view of the > fact that I will be offering PHP hosting to others, and don't want them > to do anything like this) - I would ideally like to run this script > online, but don't want to screw my host's machine. There are settings in php.ini to limit the processing time and RAM used by PHP -- These should be kicking in if they are set. The time limit can be over-ridden by a user, and maybe the RAM as well, but they have to make a concious effort to do so.

« previous php.general (#25280) next »