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

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

VM’s picture

if 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.

VM’s picture

meant 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.

VM’s picture

Assigned: Unassigned » VM
Status: Active » Closed (fixed)
klavs’s picture

Assigned: VM » Unassigned
Status: Closed (fixed) » Postponed (maintainer needs more info)

I 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?

klavs’s picture

I 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.

klavs’s picture

Status: Postponed (maintainer needs more info) » Needs review

see post #5 - about changing line 214 in modules/color/color.module.

StevenPatz’s picture

Status: Needs review » Active

There is no patch.

ainigma32’s picture

Status: Active » Postponed (maintainer needs more info)

See here http://drupal.org/patch/create for info on creating patches.

- Arie

Dave Reid’s picture

Version: 5.10 » 5.x-dev
Component: Garland theme » color.module

Problem 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.

ainigma32’s picture

Status: Postponed (maintainer needs more info) » Fixed

Looks 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

klavs’s picture

I 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?

ainigma32’s picture

Status: Fixed » Postponed (maintainer needs more info)

I 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

klavs’s picture

FileSize
937 bytes

Here's my first drupal patch - hope it is as it should be :)

I tested it and it works for me.

ainigma32’s picture

Status: Postponed (maintainer needs more info) » Needs review

Good for you! If I find some time I will see if I can test it too.

- Arie

TR’s picture

Version: 5.x-dev » 8.x-dev
Category: support » bug
FileSize
912 bytes

5.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().

marcingy’s picture

Status: Needs review » Reviewed & tested by the community
Issue tags: +Needs backport to D7

Looks sensible.

webchick’s picture

Status: Reviewed & tested by the community » Needs work

Could 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.

TR’s picture

Status: Needs work » Needs review
FileSize
1.18 KB

Added comment as requested and re-rolled the patch against the current HEAD.

marcingy’s picture

Status: Needs review » Reviewed & tested by the community
webchick’s picture

Status: Reviewed & tested by the community » Fixed

Rock! Thanks.

Committed and pushed to 8.x and 7.x.

Status: Fixed » Closed (fixed)

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

_cam_’s picture

Version: 8.x-dev » 7.12
Status: Closed (fixed) » Active

I'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.

marcingy’s picture

Status: Active » Closed (fixed)

Please do not reopen bugs for support requests.