Same problem with xmlsitemap_node in 6.x-0.x-dev as for the D5 version in http://drupal.org/node/231420. My site has a few tens of thousands of very short entries, but D5 managed this without any problem with 96 MB of memory. After conversion, everything works OK, but I get the following message even after I increased memory limit in php.ini to enormous 160M !
PHP Fatal error: Allowed memory size of 167772160 bytes exhausted (tried to allocate 71 bytes) in ................/sites/all/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module on line 15, referer: http://www............../node/264047/edit
This happened on submitting an edited page. After switching off updating sitemap on submit (new content), submitting pages works, but cron is still not running, in fact it has never managed to run, with this fatal error:
PHP Fatal error: Allowed memory size of 167772160 bytes exhausted (tried to allocate 32 bytes) in ................/sites/all/modules/xmlsitemap/xmlsitemap_node/xmlsitemap_node.module on line 22
Something's eating way too much memory somewhere. Any suggestions?
| Comment | File | Size | Author |
|---|---|---|---|
| #12 | xmlsitemap_rewrite_1_4.patch | 18.71 KB | andreiashu |
| #10 | xmlsitemap_rewrite_1_3.patch | 18.71 KB | andreiashu |
| #10 | xmlsitemap_rewrite_1_3.tar_.gz | 38.59 KB | andreiashu |
| #9 | xmlsitemap_rewrite_1_2.patch | 18.11 KB | andreiashu |
| #9 | xmlsitemap_rewrite_1_2.tar_.gz | 38.36 KB | andreiashu |
Comments
Comment #1
kamupathyr commentedThis could be due to the insufficient memory limit allocated for the script.
Every script needs some memory for it to run and the limit is defined in "php.ini" file.
The attriburte name is "memory_limit" -
How to set?
Manually - Open the php.ini file - set as --> memory_limit = 128M (try restarting Apache server)
Script: ini_set('memory_limit','128M');
Php.ini will be available in the installation path of php binaries.
Hope that helps,
Thanks,
Kamu
Comment #2
vacilando commentedI appreciate your response but, as you can see above, I normally use 96M and it is totally safe (even 64M would probably be enough), but now even 160M (set in php.ini of course) is not enough. The problem persists and I have been telling my clients and partners to stay away from xmlsitemap in D6 until there is more clarity.
Comment #3
avpadernoI am changing the referring version.
Comment #4
avpaderno@vacilando: Are you using a module that changes the Drupal cache to be kept in memory?
Is this the case for somebody who has the same issue?
Comment #5
vacilando commented@Kiam -- as for me, no, I do not use CacheRouter nor APC module if that's what you are asking about. Thanks for looking into this!
Comment #6
avpadernoI am just trying to understand what could cause the memory to become exhausted. That could have been one possibility, but it's more probable that the problem is caused from the call to
drupal_page_footer().Thanks again for your reply.
Comment #7
andreiashu commentedI did a rewrite of the xmlsitemap module that hopefully resolves this bug.
The idea: using drupal_page_footer() to cache is not ideal. Here is why:
1. Because of this bug
2. Mysql has a setting (smth like max_packet_size) that does not let you send a packed that is bigged than it. So caching the whole sitemap page in DB is not really good.
3. After the sitemaps have been generated, it should serve them faster than the current implementation.
The patch is against the the latest dev version of xmlsitemap from 2009-Jan-02.
It is not yet finished.
It needs some testing and reviewing before i/we can continue with this idea in it.
TODO:
Every TODO that is commented in the code
WARNING: please do not test this on a live site :)
I'll wait for your reviewing.
@vacilando: maybe you can test this on your host to see if you still get the error ? (of course not on the live DB)
I attached the patch and also an archive with the module rewritten.
Thanks.
Comment #8
andreiashu commentedOops I left, by mistake the xmlsitemap_rebuild TRUE by default...
Reattached the correct (hopefully) patch + archive
Comment #9
andreiashu commentedBleah... Sorry, I attached a wrong "fix".
Comment #10
andreiashu commentedI implemented 'xmlsitemap_rebuild_interval' setting so that you can fine tune how often the sitemap gets rebuilt. It defaults to 86400 (1 day).
Maybe someone can give it a spin :)
Cheers
Edit: forgot to specify that now xmlsitemap_log_access should work (manual call module_invoke_all('exit') from xmlsitemap_output).
Comment #11
avpadernoThere are the following errors in the patch:
module_invoke()is not necessary, asfile_transfer()callsexit(); therefore, after callingfile_transfer()the module has already terminated its execution._xmlsitemap_recursive_delete()wrongly calls_imagecache_recursive_delete().Comment #12
andreiashu commentedWell, the version from the 2.01.2009 doesn't work on multi-language sites either... But that is not the point of this patch...
The point of this patch is to demonstrate that you can make it work for more people (that don't have access to setting 'memory_limit' in php.ini or to my.cnf) and with less system load (even if you get mysql to cache sitemap into the cache_page table, it should be faster to dump the contents of a file directly from it than to dump it from DB, and also you need to have big mem_limit because it is a single big row of data that gets load into ram first).
I was expecting you to look over/test the main idea of this patch: don't use drupal_page_footer, but cache the sitemaps as files.
I saw that in the repository you started working on the multilanguage issue: I'm sure that you/we can merge this patch into that too. But only of course if you take a look at the patch and see that maybe it has a point.
About module_invoke() in the xmlsitemap_output func: I didn't notice that file_transfer calls exit at the end. We need the invoke exit for the logging facility. So maybe put it before file_transfer call ??
I fixed _xmlsitemap_recursive_delete().
Thanks.
Comment #13
avpadernoIt would have been better if you kept to reply on the other report about how to optimize the code, rather to start replying to this report.
To review an idea is enough the idea gets explained in detail; a patch made for code that is already being changed is a way much useless.
Like I said, the module is being changed to work on multi-language sites, so the patch you attached here still would need to be changed when 6.x-2.x-dev will be made public.
The way your code caches the content of the site map can be adopted in the branch I am developing. If you will to cooperate in making this project code better, you could write a function that creates the file name used to contain the output of the site map, which takes in consideration the language currently used by Drupal, and the domain to which the page request has been submitted (in this way the function would be compatible with multi-site Drupal installations).
Simply write the function code and attach the comment to the other report, not this one.
-- Kiam
Kiam la luno renkontas la sunon
Comment #14
andreiashu commentedI put the patch here because it is about this bug and in CVS HEAD it is not solved either. Do you solve it in 6.x-2.x-dev release ? If not then this idea is still available (from my point of view).
And I'll try to do that function.
Cheers
Comment #15
avpadernoBut it's also a patch for a better xmlsitemap performance, that is the topic of the other report.
If you keep to add comments here, then I will set the other report like a duplicate.
I don't usually commit code to CVS HEAD.
Comment #16
andreiashu commentedYup, I also think that post should be closed. You explained me thoroughly in there about those stuff and i thank you.
Why don't you commit to HEAD ? I mean, if you would, maybe there would be more ppl trying to help you. You are not alone in here... We all need this module (by submitting a bug/patch means that we had to use the module in the first place). So we should help in developing it. So by submitting a patch (or in this case more of an idea) means that I want to help.
I think that maybe tomorrow I'll have some time to look at that function you need.
Comment #17
avpadernoI don't commit in HEAD because when the code is specific for a Drupal version it is required to create a branch.
In this case I cannot commit to HEAD because it has been created a version from HEAD code (6.x-0.x-dev).
The use of CVS HEAD is not necessary, then, to get contributions.
Comment #18
andreiashu commentedI didn't forget about the function that I promised to make, but lately I had absolutely 0 free time because of my exams.
I'll try to come back ASAP. I hope that by the end of next week I'll start to make myself some time for this.
Comment #19
avpadernoThere are no worries about that, andreiashu.
Already you gave a big help in this issue. Even if I have to adapt the patch you wrote for the code I am developing, your help is well appreciated, and I thank you for what you already did.
Comment #20
Anonymous (not verified) commentedThe exhausted memory can be caused by php errors that cause a drupal_set_message. Those messages are stored in a global session cache. I suspect that #352046: Division by zero is the culprit of this issue as it is titled. I too had this issue until I fixed the division by zero error. Kiam, can you resolve the division by zero error for the published 1.x-dev version?
Comment #21
avpadernoI fixed the division by zero issue for the DRUPAL-6--1 branch. The new tarball archive will be available between 12 hours.
I think that this solves a particular case, but the exhausted memory is in general caused by the site map being served from the cache Drupal uses for the pages; this means that the site map is loaded from a database table into memory, with the result that the memory becomes exhausted when the site map contains a large number of links.
Thanks, anyway, for pointing out this case.
Comment #22
avpadernoI implemented a different way to cache the site map content, as suggested by andreiashu; it should resolve the memory issue too.
Comment #23
avpadernoI am setting the report as fixed because it didn't get any feedback in more than 2 weeks. If the project modules are still causing memory allocation failures, feel free to re-open the issue.