I loaded themekey and then installed it after saving the changed list in Modules I got an out of memory error (>32Mb).

Solution for me was to upgrade to 96Mb - I needed to do it anyway, but just thought I'd drop you a note.

Comments

epersonae2’s picture

I believe I may be having a similar problem. Three times now I've attempted to upgrade and had the whole server crash. I have 128M allocated via settings.php.

mkalkbrenner’s picture

I did some quick tests with some ThemeKey rules and ThemeKey UI. The peak memory usage was always below 32 MB. So it requires some more information about your setup and your current ThemeKey configuration.

epersonae2’s picture

I tried again, completely uninstalling ThemeKey v1 and installing v2 (beta 7) from scratch, using all default settings IIRC.

I added about 10 rules, and for 20 minutes or so it worked beautifully. Then -- I'm guessing on a cron run? the server ground to a halt. According to the guys at the colo, there was a runaway process in MySQL that ate up all available memory. It had to be rebooted with Apache off, then I deactivated the module via the status field in the system table, and restarted Apache.

We have a second instance of Drupal on the same server used purely for testing, and it has not experienced this problem at all.

PHP memory usage is set for 128MB.

mkalkbrenner’s picture

Assigned: Unassigned » mkalkbrenner
StatusFileSize
new984 bytes

ThemeKey itself doesn't implement hook_cron. But here's a patch to turn off ThemeKey when cron runs. Does it solve your problem?

mkalkbrenner’s picture

Status: Active » Needs review
adrianmak’s picture

subscribe

mkalkbrenner’s picture

Version: 6.x-2.0-beta7 » 6.x-2.0-rc2

Please provide some feedback to this issue after upgrading to ThemeKey 6.x-2.0-rc2 which contains patch from comment #4.

epersonae2’s picture

Will do...am waiting on an unrelated server upgrade before I try this.

Dr Jay’s picture

+1 and I can confirm that I am using the rc2 update with the included patch. Am getting a Maximum execution time of 30 seconds exceeded message and the process keeps respawning.

UPDATE: here is the error:

[Thu Apr 08 11:14:36 2010] [error] [client 208.115.111.244] PHP Fatal error: Maximum execution time of 30 seconds exceeded in /home/jdaverth/public_html/nala.ie/sites/default/modules/themekey/themekey_base.inc on line 62

Dr Jay’s picture

For what its worth, the error is kicking up on line 62, which for some reason is resulting in a long (maybe infinite) loop (even increasing max_execution to 60 did not solve the problem:

    // REVIEW Is there a more efficient algorithm?
    for ($i = 0; $i < count($ancestors); $i++) {
       $ancestors = array_unique(array_merge($ancestors, themekey_add_path_ancestors($ancestors[$i])));

I don't understand the code well enough yet to tell if the problem is coming from the loop itself (i.e. how large is count($ancestors); or from the function call to _add_path_ancestors.

ManyNancy’s picture

Theme key really makes my site slow.

mkalkbrenner’s picture

@Jay Daverth #10:
The line where the error is kicking up doesn't need to be the root cause for the error. It might happen that in this line the memory usage just increased a little but brake the limit (like from 31.999 MB to 32 MB).
Nevertheless this part of the code is suspicious and I'll have a look at it.

@ManyNancy #11:
can you help us be providing some more information like amount of ThemeKey rules and which properties you use.

mkalkbrenner’s picture

Component: Installation / Configuration » Code / API
Priority: Minor » Critical
StatusFileSize
new10.06 KB

I reviewed the code. I think the current algorithm to detect the values of drupal:path causes the trouble described in this issue.
Unfortunately it takes a heavy patch to use a more efficient approach.

It would be helpful if somebody reviews or tests my patch because such a change is exceptional for a release candidate.

mkalkbrenner’s picture

StatusFileSize
new10.12 KB

Found a small bug in my latest patch. Here's an updated one.

mkalkbrenner’s picture

fixed a small bug in latest patch and released ThemeKey 6.x-2.0-rc3: http://drupal.org/node/776634

It would be nice if anyone confirms that this issue is resolved.

epersonae2’s picture

I should be able to do that within the next two weeks. (Still waiting on that server.) Will definitely post as soon as I know, one way or the other.

ManyNancy’s picture

RC3 is giving me errors:

Fatal error: Allowed memory size of 100663296 bytes exhausted (tried to allocate 65536 bytes) in /vol/www/pressflow/includes/theme.inc on line 1064

RC2 did not, so the new patch has some problems in it, unless there's some upgrade steps that needs to be taken that I was not aware of.

Thanks.

I have 8 rules, 2 node type rules and 6 drupal:paths rules.

ManyNancy’s picture

Version: 6.x-2.0-rc2 » 6.x-2.0-rc3

Edit: Wait, sorry, problem probably not caused by this module. I tried to set init_theme myself with this module turned off and am still getting this. :(

kfritsche’s picture

I tried it on our site and it works great.

I added up to 10 drupal:path urls for testing and stop the time themekey needed to detect which rule to take (function themekey_match_rule_childs).

Before the patch it depends on the path length.
For a path like /event/2010/05/21/month/all/all/1 it needed up to 6s (SECONDS!)
For a path like /de/event/2010/05/21/month/all/all/1 it needed up to 27s!

After the patch it needs for all request some microseconds.

So for all, which have trouble and getting a out of memory or execution time exceeded error, should really test the patch (or RC3).

mkalkbrenner’s picture

Status: Needs review » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

epersonae2’s picture

BTW, I finally had a chance to reinstall ThemeKey on our production server and so far it seems to be working fine.