1
votes

This is the error I'm getting using some features of moodle on a shared hosting provider:

Fatal error: Allowed memory size of 67108864 bytes exhausted (tried to 
allocate 76 bytes) in /home/myusername/public_html/lib/moodlelib.php on line 8071

First I thought the php memory limit was set too low, but 64MB seems perfectly acceptable... Is moodle so memory-hungry that it would need more than that?

If that's the case, and considering I'm using a shared hosting and that it's likely unlikely they will increase the memory limit just for me, how can I work around it?

I'm using moodle 2.4.3.

2
Have you tried debugging to see if you are stuck in some infinite loop? - Mike Brant
The message appears too often and using very different moodle features, so I think that's not it. The php file and line number aren't always the same. - Filipe Correia
I wouldn't expect the line number to always be the same, but I would guess that perhaps these line numbers are all within some common section of code where you are trying to put a large amount of data in memory. - Mike Brant
Yes, that makes sense. But how can I work around it? :( - Filipe Correia
You don't work around it. You need to find out why you are trying to allocate this much memory. Debug your application. - Mike Brant

2 Answers

1
votes

Moodle provides a function to raise memory limit. If you do not have access to the php.ini file, you can configure Moodle to do so.

Edit the config.php file within the moodle root directory. Add raise_memory_limit(MEMORY_STANDARD); or raise_memory_limit(MEMORY_EXTRA); to the end of that file (somewhere behind require_once([...]setup.php');).

0
votes

64MB seems perfectly acceptable... Is moodle so memory-hungry that it would need more than that?

In short: yes!

We used to have the same problem. Our php.ini's memory_limit setting has been set to 256M for quite some time. (We're currently using Moodle 2.6, but we saw this problem with 2.1 or 2.2 if memory serves.)

Memory use will vary with Moodle use, of course, but we kept on increasing the setting by 32Mb until the problem went away. (We do run our own servers so adding physical memory is a no-brainer.)