I am receiving the following out of memory error: Fatal error: Out of memory (allocated 19922944) (tried to allocate 30720 bytes) in /home/hostitif/public_html/sites/all/modules/print/print.module on line 352

This is for a website that I am moving from one host to another. I was able to move the website successfully but then it stopped working after about 2 days. The developers working on the site said that they did not change any settings.

The strange thing is I can verify that we are setting the memory limit well above the "allocated" amount specified above. I currently have it set to 128M and can verify this with phpinfo() on the root folder of the Drupal install.

http://transfer.itif.org/

http://transfer.itif.org/phpdata.php

Any ideas?

I have tried restoring the Drupal database, all Drupal files, clearing the cache and reinstalling Apache.

I have also tried manually setting the memory_limit in /sites/default/settings.php and in .htaccess. I am completely stumped why the allocated memory is not higher. (I am on a VPS with 1 GB memory available).

Any help would be appreciated. Thanks.

Comments

cog.rusty’s picture

You seem to run out of memory at 19M.

What does the admin/reports/status page inside Drupal say about the PHP memory limit? If it says 128M then maybe the web server sets another limit.

dcastro’s picture

How do I see the admin/reports/status page? Just browse to that location? I get the same type of out of memory.

cog.rusty’s picture

Hmm... yes that is a problem.

Because the memory_limit can be set in 3 different places, in php.ini, in .htaccess per directory, and in drupal's settings.php at runtime, and the latter settings override the former, I wanted to know which settings Drupal finally gets.

Normally, if you haven't set a memory_limit in Drupal's settings.php file with an ini_set('memory_limit', 'xxM') line, then the one reported by a phpinfo() file inside Drupal's directory is the true one.

Anyway, try this in a checkmem.php file inside Drupal's directory and see at which point it crashes with an "out of memory" error.

ini_set('display_errors', 'On');
$new_mem_limit = '128M';
$old_mem_limit = ini_set('memory_limit', $new_mem_limit);
print 'Memory limit changed from '. $old_mem_limit .' to '. $new_mem_limit .'<br />';

$step = 1;
while(TRUE) {
  $chunk = str_repeat('0123456789', 1024*1024*$step++);
  print 'Memory usage: '. round(memory_get_usage()/(1024*1024)) . 'M<br />';
  unset($chunk);
}

That is the real test of how far your php memory can go.

dcastro’s picture

When I run the script, this is the output I see:

Memory limit changed from 256M to 128M
Memory usage: 10M

Fatal error: Out of memory (allocated 262144) (tried to allocate 20971521 bytes) in /home/hostitif/public_html/checkmem.php on line 9

Yes, it definitely seems to be running out of memory. What could be a cause of this?

http://transfer.itif.org/checkmem.php

dcastro’s picture

I've added the line:

RLimitMem 128000000

to the .htaccess file and this seems to have fixed the problem. Although I'm still not sure I understand the cause.

cog.rusty’s picture

So, there was an apache limit.

nathanjo’s picture

Yeah seems out of memory issue. Try if this can help http://drupal.org/node/76156. Also check your hosting provider.

dcastro’s picture

Yep, I've done all of those items. And as you can see in the phpinfo(), the system shows the memory is there, but Drupal doesn't.

Yuki’s picture

Sbscribe