How can I increase the shell's (or specific application's) memory limit?

Olaf Greve o.greve at axis.nl
Mon Apr 3 11:42:15 UTC 2006


Hi,

I've got a question which is probably pretty easy to answer: how can I 
assign more memory to a PHP script running in a shell and/or in a browser.

Some more background info:
I'm building a PHP script that has to retrieve pretty large sets of data 
from a remote MySQL database, then process it, and store the results to 
a local database.

The issue:
The script (surprise, surprise) quickly runs out of memory. Now, I have 
already tried to increase the memory limit in php.ini (followed by an 
Apache restart, of course), but even when setting the limit to something 
high like 384MB or so, the script still bails out with a memory limit 
error when retrieving as little as some 50MB of data...

Now, of course I could rewrite my PHP script such that it will retrieve 
smaller batches of data, but being a programmer I'm lazy, and I'd rather 
simply assign more memory to the script (actually, it's not only due to 
laziness, but also due to the fact that the script has to agregate data 
etc., and I'd rather have it do that in 1 run for a variety of reasons).

It seems to me like setting the memory limit in php.ini above a value of 
64MB (or so) doesn't seem to have any effect anymore. My assumption then 
is that the memory limit is somehow enforced elsewhere (the shell 
perhaps, and/or Apache?).

Can anyone tell me how to adjust this such that I can successfully 
assign say 384MB of memory to PHP scripts ran both from browsers (i.e. 
through Apache 2.2 and mod_php) as from the commandline?

Tnx in advance, and cheers,
Olafo



More information about the freebsd-questions mailing list