Hey everyone,
I've been trying to change the color scheme on my Garland theme that is standard for Drupal 5.1. However, when I try to do so, I get the following error...
There is not enough memory available to PHP to change this theme's color scheme. You need at least 2.06 MB more. Check the PHP documentation for more information.
Any ideas on how to fix this (I'm kinda new to Drupal and PHP).
Thanks,
James
Comment | File | Size | Author |
---|---|---|---|
#18 | 123983-memory-usage.patch | 1.18 KB | TR |
#15 | 123983-memory-usage.patch | 912 bytes | TR |
#13 | drupal-color-module.patch | 937 bytes | klavs |
Comments
Comment #1
VM CreditAttribution: VM commentedif you are running your own server, adjust php.ini
if you are on a shared host, you have to have them adjust your php.ini or ask them if you can use a custom php.ini and adjust the memory_limit to 12 and place in your drupal root folder.
Comment #2
VM CreditAttribution: VM commentedmeant to add that not all shared hosts will adjust this memory_limit. PHP default sets memory_limit to 8 MB. If your host does not allow you to either customize the php.ini or they don't adjust it for you, and you really want the color picker module, you will have to seek out a new host who is not so limiting.
Comment #3
VM CreditAttribution: VM commentedComment #4
klavs CreditAttribution: klavs commentedI have the exact same message - and it only comes after quite some time with "saving" the theme settings.
I have memory_limit set to 50M's now (it was 16 - but then it started showing up, and I increased it - which helped for a while).
It seems there's somewhere it builds up the size - so it ends up growing larger and larger.
I tried stopping and starting apache (verifying that it was indeed stopped) - but the problem persists.
it says it needs 10.59M's more memory - and a phpinfo() agrees with me - that memory_limit = 50M.
I altered color.module to tell me how much memory it thinks PHP is using - and it reports it's using 56M and that 3M is required.
How do I find out, what drupal module is eating all my php memory?
Ideas?
Comment #5
klavs CreditAttribution: klavs commentedI commented out the section checking for size (line 204->220) - and now it updates the theme without any problems. I tried changing from teal to custom and back - without any problems.
It seems the function get_memory_usage - according to: http://dk2.php.net/manual/en/function.memory-get-usage.php actually reports the usage of the entire process (which means the number includes what apache uses) - and that's why it doesn't work as expected.
doing this instead worked for me:
$usage = memory_get_usage(1);
(notice the (1) - instead of ())
It also seems more correct - since it reports what is actually allocated - and not just what is reserved.
Comment #6
klavs CreditAttribution: klavs commentedsee post #5 - about changing line 214 in modules/color/color.module.
Comment #7
StevenPatzThere is no patch.
Comment #8
ainigma32 CreditAttribution: ainigma32 commentedSee here http://drupal.org/patch/create for info on creating patches.
- Arie
Comment #9
Dave ReidProblem with that solution is that the $real_usage parameter was added to memory_get_size in PHP 5.2.0, so the fix will not work for anyone running PHP 5.1.x and below, which currently is a lot of users.
Comment #10
ainigma32 CreditAttribution: ainigma32 commentedLooks like klavs won't be posting any feedback so I'm setting this to fixed.
Feel free to reopen if you think that is wrong.
- Arie
Comment #11
klavs CreditAttribution: klavs commentedI don't quite know how your process works here - so any tips would be well appreciated :)
I can understand (from post #9) that the solution I suggested only works in php-5.2.0+
I could insert an if (phpversion() => 5.2) which switches between an argument of 1 or the way it was before. I'll do my best to verify that that will actually work - haven't used phpversion() before :)
do you want a patch for this, against the latest 5.x release?
Comment #12
ainigma32 CreditAttribution: ainigma32 commentedI suggest you write a patch that you think does the job best. Then anyone will be able to comment on the code and make modifications along the way.
- Arie
Comment #13
klavs CreditAttribution: klavs commentedHere's my first drupal patch - hope it is as it should be :)
I tested it and it works for me.
Comment #14
ainigma32 CreditAttribution: ainigma32 commentedGood for you! If I find some time I will see if I can test it too.
- Arie
Comment #15
TR CreditAttribution: TR commented5.x is no longer supported, but this code is still present in 7.x and 8.x so I'm changing the version and updating the patch to call memory_get_usage(TRUE) instead of plain old memory_get_usage(). The check on PHP version doesn't need to be made because Drupal 7.x and 8.x already require PHP 5.2.
This is the only place in core that uses memory_get_usage().
Comment #16
marcingy CreditAttribution: marcingy commentedLooks sensible.
Comment #17
webchickCould we add a quickie one-liner comment to that line? There's a lot of discussion here that's not adequately captured in the code.
Comment #18
TR CreditAttribution: TR commentedAdded comment as requested and re-rolled the patch against the current HEAD.
Comment #19
marcingy CreditAttribution: marcingy commentedComment #20
webchickRock! Thanks.
Committed and pushed to 8.x and 7.x.
Comment #22
_cam_ CreditAttribution: _cam_ commentedI've reopened this for a quick question:
If (the memory_limit is set to -1 (unlimited) )
then
the test will be: if ($usage + $required > $limit) where $limit will be 1
Am i correctly assuming that just about any value will be greater than 1?
Thank you.
Comment #23
marcingy CreditAttribution: marcingy commentedPlease do not reopen bugs for support requests.