Out of memory error

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I know the memory limit for a script is configurable, but are there
any limits?

I am generating a pdf file with lots of images.

With a limit of 64M, I can build a report with 5000 images. But once I
go above 7000 I get the following error:

Fatal error: Out of memory (allocated -1364983808) (tried to allocate
71564895 bytes) in /user1/web/run/htdocs/test/fpdf16/fpdf.php on line

Even setting memory_limit = 1024M and restarting apache does not fix
the problem. The server has almost 8 GB of free physical memory.

Any ideas?


Re: Out of memory error

Mark Smith wrote:
Quoted text here. Click to load it

I don't think there is any limit built into PHP, but you do have on in
your OS.  If you're using a 32 bit system, each process will be limited
to 4GB less whatever the OS needs and some other things.  If you're
running PHP as a module, you will have to also subtract all the memory
required by Apache and all other PHP processes being run concurrently.

With a 64 bit system (and everything compiled for 64 bit), you'll
obviously have more room available.  But if you run PHP as a CGI (or
standalone), you should also have more space available (as PHP will run
in its own process).

I've used 128MB with no problems, but never needed to go higher.

Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.

Re: Out of memory error

Jerry Stuckle wrote:
Quoted text here. Click to load it
Ditto here. on 32 bit system. I needed to upload a 65Mbyte file..it was
a mistake, but I set it up and it worked. I then deleted that file !!

Run phpinfo to see what you actually have registered.

You will need to restart apache to pick up any changes to php.ini, if
indeed you have edited the one in use....

you should not be restricted to actual physical RAM anyway..what
restricts is the size of the memory pointers in use.

If PHP is simply doing malloc() style calls to the OS, then likely as
not the OS will page out memory into swap to lt it, up to and including
whatever the limit is.

So in theory 4GB is available less whatever php/apache uses itself.

Re: Out of memory error

Quoted text here. Click to load it

Never had reason to run with more than 32Mb.

It'd be useful to know what OS you're running on, and whether PHP was
complied as 32 or 64 bit.

Is the error message **exactly** the same with 1024M?

Have you used you OS tools to find out how much memory the script is
actually using? Have you tried instrumenting your code to log
memory_get_usage() ?


Site Timeline