1

I have a Drupal based web site on a relative small vserver (512MB RAM). Recently the website begins to return php out of memory messages like this:

Fatal error: Out of memory (allocated 17039360) (tried to allocate 77824 bytes) in /home/...

All php.ini memory limit parameters are set to off (-1).

Propably the website has gained of complexity, content, etc. But I cannot interpret fine that message: Does that mean that the whole request has allocated 17MB(?) right now and cannot get 7KB(?) more from the OS. Has the web server spend all memory or has the OS no more memory to allocate ?

I'm not shure if the memory overhead is coming from the web server or another service, because when I get the out-of-memoy message I can't get into the server with ssh. After a while all runs fine again.

3
  • 1
    Is that 512MB for the whole server? Do you have anything else running on that server? 17,039,360 bytes = 16.25MB and 77,824 bytes = 76KB which isn't very much at all. Yes, PHP is requiring more memory (in order to process the request and generate a response). PHP 5.2 had a default memory_limit of 16M, but you say this is set to -1 (unlimited). This would appear to suggest your webserver/PC is the limiting factor. My development server consumes 800+MB when idle.
    – MrWhite
    Dec 16, 2012 at 15:37
  • w3d is probably right, but 16.25MB for a PHP script isn't that too much ? I've never experienced more than 3MB used on a relatively complex page... so I would suggest you check memory peak usage with this function memory_ get_ peak_ usage() called at the end of your script and maybe this one memory_get_usage() to seek where your script is allocating most memory.
    – WiMantis
    Dec 16, 2012 at 18:09
  • Also note that as far as server memory is concerned, if you have multiple users on your site, then each request is potentially going to require the same amount of memory.
    – MrWhite
    Dec 17, 2012 at 10:00

3 Answers 3

1

In php.ini set the following,

memory_limit = 100M
post_max_size = 100M

Furthermore, its worth noting if you are uploading a image via the GD send libary then you are sending a image that will be uncompressed in memory. So for example if its a 3000x3000 file the actual size if using GD is:

width * height * bit-depth, e.g., 3000*3000*32 = 288000000 bits = 34 MB

It's also worth mentioning that 512mb these days for any linux build is a low amount for a LAMP, even if the site is small and only has a few visitors each day the memory usage is near its max, and depending on what your uploading can be an issue. Many VPS's disable the SWAP as the VPS owners do not want CONSTANT disc writes which slow down the other VPS's (Disks cause Lag on VM Servers with SWAP enabled).

So the changes are the file is simply to big and your running out of memory, assuming that your using a good vps provider you should be able to scale up the memory to 1gb and see if it still recalls this error.

1
  • The OP states they already have the memory_limits set to -1 (unlimited), but are you saying that setting a memory_limit is preferable?
    – MrWhite
    Dec 17, 2012 at 9:57
1

Have you added any new modules to the site? It could be a memory leak in a script or endless loop. But they'll typically generate high CPU usage.

You should consider installing xdebug ( http://www.xdebug.org/ )you will get detailed errors about the application to figure out the problem area. This is mostly used by developers though.

1

Found a possible duplicate on Stackoverflow and its answer

Have you tried killing the previous apache threads?

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .