Allowed memory size exhausted

Post

Posted
Rating:
#3324 (In Topic #650)

I'm getting frequent "Critical Errors" on my site with the error being the "Allowed memory size of XXXXXXX bytes exhausted (tried to allocate XXXXXX bytes) in sources/caches3.php on line 331."

I've increased the php_memory limit and added additional swap memory for the site but these don't seem to resolve the issue. I end up having to flush the cache to alleviate the error, but I don't want to have to mannual do that every time the error pops up. Is there some setting I'm missing that is causing this issue?

Post

Posted
Rating:
#3325
Can you please give us an example of what XXXXXX is?

Post

Posted
Rating:
#3326
Also, a list of places the error occurs.

Post

Posted
Rating:
#3327
Here is the most recent example in the error log:

25-Oct-2017 08:37:31 UTC   PHP Error   Allowed memory size of 67108864 bytes exhausted (tried to allocate 343467 bytes) in sources/caches3.php on line 331

The latest place that it has been encountered by users when they try to access the form to join the site. The "Critical Error" page appears rather than the join form.

Post

Posted
Rating:
#3328
Okay, thanks.

I may need to look directly on the server to run tests. If you are able to provide that access (E.g. FTP details), please e-mail to chris@ocproducts.com.

Regardless, I will see if I can see any memory bottlenecks on this page.

Post

Posted
Rating:
#3329
Hi,

I suspect you may have placed some large files in one of the template directories.

Check you haven't accidentally uploaded alien files to any of these directories:
themes/*/css
themes/*/css_custom
themes/*/javascript
themes/*/javascript_custom
themes/*/templates
themes/*/templates_custom
themes/*/text
themes/*/text_custom
themes/*/xml
themes/*/xml_custom

The error message suggests a file at least 300kb in size, which is unlikely for a template file, but I suspect you have a lot of alien files in there.

Post

Posted
Rating:
#3330
Default directory sizes in bytes for these directories…

Code

8   xml_custom
40   text_custom
144   xml
176   text
216   css_custom
888   javascript_custom
1184   css
1352   templates_custom
4584   javascript
8056   templates

Post

Posted
Rating:
#3331
And this fix for sources/caches3.php will stop it reading irrelevant file types within template directories:
https://raw.githubusercontent.com/ocproducts/composr/f79e2e8b9893e6ffbdca2b4e7a35451ce5521fa0/sources/caches3.php

That will probably fix the issue for you also.

More detail:
When certain automatic cache flushes happen it limits cache flushing of templates based on ones matching certain patterns only within their data. To do this it has to read all the templates. If there's alien files in there it is reading in all that data unnecessarily. The hotfix will target what files it will read.

Post

Posted
Rating:
#3332
I don't see any alien files, just .tpl files but the templates_custom folder has multiple versions (differentiated with an appended number) of some of the more commonly edited templates. I've switched out the caches3.php file with the one provided and I'll monitor to see if the issue persists. Thanks so much for the help!

Post

Posted
Rating:
#3333
Ah, those multiple versions could be it, something I'd not considered to be there in large quantity. I'm confident my fix will resolve that.
1 guest and 0 members have recently viewed this.