PHP memory limit? 
Author Message
 PHP memory limit?

One of my scripts keeps stopping at the same point with the following  error
message

FATAL: emalloc(): Unable to allocate 16 bytes

The script is very memory hungry, so I tried increasing the "memory_limit"
parameter in php.ini to a (much) larger number but the script still stops at
the same point.

Is there an upper limit for the amount of memory that a script may consume?
I am using php 4.2.2 on windows 2000.

Thanks



Mon, 30 May 2005 09:03:02 GMT  
 PHP memory limit?

Quote:

> One of my scripts keeps stopping at the same point with the following
> error message

> FATAL: emalloc(): Unable to allocate 16 bytes

> The script is very memory hungry, so I tried increasing the "memory_limit"
> parameter in php.ini to a (much) larger number but the script still stops
> at the same point.

> Is there an upper limit for the amount of memory that a script may
> consume? I am using php 4.2.2 on windows 2000.

> Thanks

The absolute limit is set by Apache.  However, if your program is
misbehaving in this way, a program logic-error is strongly implied.


Mon, 30 May 2005 09:13:48 GMT  
 PHP memory limit?


Quote:

> > One of my scripts keeps stopping at the same point with the following
> > error message

> > FATAL: emalloc(): Unable to allocate 16 bytes

> > The script is very memory hungry, so I tried increasing the
"memory_limit"
> > parameter in php.ini to a (much) larger number but the script still
stops
> > at the same point.

> > Is there an upper limit for the amount of memory that a script may
> > consume? I am using php 4.2.2 on windows 2000.

> > Thanks

> The absolute limit is set by Apache.  However, if your program is
> misbehaving in this way, a program logic-error is strongly implied.

I am running the script from the command line so I do not think apache is
involved. Also, the logic error can probably be ruled out too because the
script works fine on smaller datasets.

It translates between various 3d file formats and is failing whilst
processing a particularly large file.



Mon, 30 May 2005 09:19:56 GMT  
 PHP memory limit?

Quote:

>> The absolute limit is set by Apache.  However, if your program is
>> misbehaving in this way, a program logic-error is strongly implied.

> I am running the script from the command line so I do not think apache is
> involved. Also, the logic error can probably be ruled out too because the
> script works fine on smaller datasets.

> It translates between various 3d file formats and is failing whilst
> processing a particularly large file.

If the system is unable to allocate "16 bytes" then it's well-hosed by that
point and nothing can save it.  Many algorithms that appear to work and
that even /do/ work under "normal" loads can fail due to weaknesses that
appear only under extreme stress.  So the assertion that "a logic error can
probably be ruled out" does not /de/ /facto/ hold true in practice.

It seems a bit amazing to me that you'd be doing this kind of work in PHP to
begin with, vs. writing a separate custom-function and calling it from your
PHP script.  Any weakness in the PHP internal system would of course be
brought to the surface by extreme stress just as surely as any weakness in
your algorithm might be.



Mon, 30 May 2005 11:39:20 GMT  
 PHP memory limit?


Quote:

> >> The absolute limit is set by Apache.  However, if your program is
> >> misbehaving in this way, a program logic-error is strongly implied.

> > I am running the script from the command line so I do not think apache
is
> > involved. Also, the logic error can probably be ruled out too because
the
> > script works fine on smaller datasets.

> > It translates between various 3d file formats and is failing whilst
> > processing a particularly large file.

> If the system is unable to allocate "16 bytes" then it's well-hosed by
that
> point and nothing can save it.  Many algorithms that appear to work and
> that even /do/ work under "normal" loads can fail due to weaknesses that
> appear only under extreme stress.  So the assertion that "a logic error
can
> probably be ruled out" does not /de/ /facto/ hold true in practice.

> It seems a bit amazing to me that you'd be doing this kind of work in PHP
to
> begin with, vs. writing a separate custom-function and calling it from
your
> PHP script.  Any weakness in the PHP internal system would of course be
> brought to the surface by extreme stress just as surely as any weakness in
> your algorithm might be.

I never intended to be working with models as large as the one I am
currently trying to process. I am preprocessing finite element meshes used
to simulate 2 dimentional flow of water. A typical mesh has of the order of
10 to 20 thousand elements. My code has been able to manage with meshes
containing up to 200,000 elements but PHP is very slow as you have pointed
out. There is no algorithm as such, just import/export type functions.

The mesh I am currently trying to process has over 1 million elements. It is
not for a finite element model but is a terrain model, hence the larger
size. It appears I have reached some kind of upper limit with regards to the
memory a php script can consume (seems to be around 1.5 to 2 gB).

The mesh is stored in a mysql database so it is easy to write some functions
to do the same things without having to load all of the data into memory at
one time. However, I would still like to know if a limit actually exists or
if there are other factors causing the error I described.

By the way, I tried to optimise the original script a little and managed to
get a little further (another 70,000 elements were processed before
crashing) but this time the error was: "FATAL: emalloc(): Unable to allocate
35 bytes" as opposed to the "16 bytes" I mentioned before.



Mon, 30 May 2005 12:12:20 GMT  
 PHP memory limit?

Quote:
> One of my scripts keeps stopping at the same point with the following
error
> message

> FATAL: emalloc(): Unable to allocate 16 bytes

> The script is very memory hungry, so I tried increasing the "memory_limit"
> parameter in php.ini to a (much) larger number but the script still stops
at
> the same point.

do you really need all that memory? I.e maybe you are keeping references to
objects that are no longer needed? If value is no longer needed you can set
varibale pointing to it to '' or something similar. Also if you are doing
function calls, maybe you can transfere some of your large arguments as
reference instead of default copying? Those things may help you reduce
memory usage.

rush
--
http://www.templatetamer.org/




Mon, 30 May 2005 19:53:51 GMT  
 PHP memory limit?


Quote:
> > One of my scripts keeps stopping at the same point with the following
> error
> > message

> > FATAL: emalloc(): Unable to allocate 16 bytes

> > The script is very memory hungry, so I tried increasing the
"memory_limit"
> > parameter in php.ini to a (much) larger number but the script still
stops
> at
> > the same point.

> do you really need all that memory? I.e maybe you are keeping references
to
> objects that are no longer needed? If value is no longer needed you can
set
> varibale pointing to it to '' or something similar. Also if you are doing
> function calls, maybe you can transfere some of your large arguments as
> reference instead of default copying? Those things may help you reduce
> memory usage.

I am already making extensive use of references in my script and no, I
probably don't need all that memory.But I'm not asking how I can make my
script work, I'm just asking if there is an absolute upper limit for the
amount of memory that a PHP script may consume. It's a simple question that
has nothing to do with my script at all, it is about the underlying PHP
engine nand whether or not there are limitations with regards to the amount
of memory a script may consume.


Tue, 31 May 2005 03:55:45 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. Memory limit << actual memory available

2. Memory usage of PHP script/arrays and memory restriction/error

3. Smalltalk Memory Limits

4. Memory limit, where?

5. Q: Squeak's memory limit

6. Limits on memory/number of objects?

7. DOS memory limit

8. PROLOG ERROR - rom: MEMORY LIMIT (pop_prolog_lim) EXCEEDED

9. Memory Limits in OS/2 REXX???

10. Looking for a way to limit physical memory used by windows95

11. Dos memory limit

12. MS Powerstation 4.0 memory limit bugs

 

 
Powered by phpBB® Forum Software