HTML Logo by World Wide Web Consortium (www.w3.org). Click to learn more about our commitment to accessibility and standards.

Moving forward with Composr

ocPortal has been relaunched as Composr CMS, which is now in beta. ocPortal 9 will be superseded by Composr 10.

Head over to compo.sr for our new site, and to our migration roadmap. Existing ocPortal member accounts have been mirrored.


Fatal Error: Memory Exhausted

Login / Search

 [ Join | More ]
 Add topic 
Posted
Rating:
#67434 (In Topic #14375)
Avatar

Fan in training

Hello everyone,

This is my first time posting here so go easy on me. ;)

I have an unusual problem on my site that I have not been able to figure out why I keep getting the error. The error is the following:

[16-Mar-2011 00:00:34] PHP Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 22500 bytes) in /home/xxxxx/public_html_net/sources/images.php on line 460

[16-Mar-2011 00:12:14] PHP Fatal error:  Allowed memory size of 67108864 bytes exhausted (tried to allocate 5625 bytes) in /home/xxxxx/public_html_net/sources/images.php on line 460
To make long story short, I upgraded my site from v5.0.3 to v6. This error comes in play when any user in the community tries to upload an image to the gallery. This error only happens on v6. When I roll back to v5.0.3 this error doesn't come up. The only thing I can think of is that something was changed on v6 in which is causing this error. What that may be I'm not sure as I haven't played around long enough with this new CMS. So I humbly ask for help here if you can help me pinpoint my problem. I would greatly appreciate it.

Oh and before I forget, the images that were uploaded were not that big at all. They range from around 500kb to 2-3MB.

Thank you for any assistance. ^^
Back to the top
 
Posted
Rating:
#67435
Avatar

Community saint

It might be that your host is just not allocating enough memory for your use.

I had memory problems with v5.0.3 at my old host which ment every time I did a search on the admin screen it would run out of memory. Their allocation was 128MB.

When I moved to my new host the first thing I tried was the search and all was well. When I checked how much memory the new host allocated to me it was 500MB, a big difference.

I'm sure v6 uses more memory then v5.0.3. Its fairly common that newer versons of software typically use more memory then previous ones as functionality increases between versions.

I doubt that the size of the files being uploaded (anything more then a few hundred KB anyway) has anything to do with your problem. You are probably just operating at the edge of available memory.

Your host will also have a max upload file size limit (my previous host was only 2MB) but I don't think that is being reached because I would expect some sort of disk space error and not a memory error.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#67436
Avatar

Fan in training

I see what you are saying. So what would be the minimum requirement for v6? My host currently has the memory_limit capped at 64MB and cant be changed since its shared hosting.

And if this is the case, I may either have to stick with v5.0.3 or possibly another CMS, as having a functional Gallery is necessary for the type of site I will be running.
Back to the top
 
Posted
Rating:
#67437
Avatar

Community saint

I have no idea what the memory requirements are for ocPortal or any of its components.

I'm sure Chris Graham, or others from ocProducts, will enlighten us.

Have you actually asked you host about getting an increase?

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#67438
Avatar

Fan in training

Yes i have but not for my website. I would have to either upgrade to VPS or Dedicated Hosting and at the moment, I can't afford either of them.
Back to the top
 
Posted
Rating:
#67439
Avatar

ocPortal 6 actually uses less memory, but imposes a memory limit of 64MB. This is part of our work to squash any scalability problems. However, ocPortal should raise the limit when it is doing something difficult like thumbnail generations (it's the image resolution not the image filesize that makes the difference here). I'll look into it.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#67440
Avatar

This should fix it.

Attachment
sources/images.php
» Download: images.php (22 Kb, 287 downloads so far)


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#67449
Avatar

Fan in training

Thanks Chris, this actually fixed the problem. But…

I started uploading different resolution type of images ranging from less than 1024px up to about 4000-5000px and came across this error after uploading 3 images:

Fatal error: Out of memory (allocated 72351744) (tried to allocate 11052 bytes) in /home/xxxxx/public_html/dev/sources/images.php on line 462

No matter what image I upload now, even if its small, it wont upload and give me this error.

Thank you for the help guys.  :thumbs:
Back to the top
 
Posted
Rating:
#67451
Avatar

Community saint

Goshujin-sama said

… I would have to either upgrade to VPS or Dedicated Hosting …

This sounds very much like my web hosts, HOSTGATOR.

I've encountered this 'problem' several times in the past, and another that you might also come across, which I will list here …
  • 'Out of memory' error
  • 'URL too long' error
On either of these, my hosts have been unable to offer a solution - BUT - what has worked for me in the past is to clear my browser cache and then use ocPortal's built-in tools to clear other caches.

Voilá, the problem goes away!

Give it a try. Nothing to lose.

 :thumbs:

Take my advice. I'm not using it!

View my working ocPortal site (version 9.x.x) at Anglo-Indian Portal
Back to the top
 
Posted
Rating:
#67454
Avatar

Does this fix it?

Attachment
sources/images.php
» Download: images.php (22 Kb, 282 downloads so far)


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#67458
Avatar

Fan in training

Fletch said

This sounds very much like my web hosts, HOSTGATOR.
What's pretty funny is that, that IS my current webhost. XD

Fletch said

On either of these, my hosts have been unable to offer a solution - BUT - what has worked for me in the past is to clear my browser cache and then use ocPortal's built-in tools to clear other caches.
I have done both but still get the error. :(

Chris Graham said

Does this fix it?
Fatal error: Out of memory (allocated 72351744) (tried to allocate 20000 bytes) in /home/xxxxx/public_html/dev/sources/images.php on line 477

:|

I cleared the cache before re-trying.

Thanks again for the help. ^_^


Last edit: by Goshujin-sama
Back to the top
 
Posted
Rating:
#67460
Avatar

Community saint

Goshujin-sama said

I started uploading different resolution type of images ranging from less than 1024px up to about 4000-5000px and came across this error after uploading 3 images:
Just F.Y.I. In v6 and without Chris' patches the maximum image size the thumbnailer can handle on my server is approximately 2,270×2,270. For me that's not an issue as the max size I expect to be uploaded is 1920x1080.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#67462
Avatar

Fan in training

temp1024 said

Just F.Y.I. In v6 and without Chris' patches the maximum image size the thumbnailer can handle on my server is approximately 2,270×2,270. For me that's not an issue as the max size I expect to be uploaded is 1920x1080.

I noticed this as well. Any reason why that is? Is it due to GD?

Which reminds me, there is a setting under Configuration -> Feature Options -> Galleries -> "Maximum Image Size". What is that for then? O.o
Back to the top
 
Posted
Rating:
#67463
Avatar

Community saint

Goshujin-sama said

Which reminds me, there is a setting under Configuration -> Feature Options -> Galleries -> "Maximum Image Size". What is that for then? O.o
As the description for that property states "this only works if the GD image library is enabled" I'm guessing that the GD image library is not actually installed on our servers and therefore this limit is not being enforced.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#67472
Avatar

Right, at this point I think there are three possibilities:
  1. Our "fudge factor" for working out how much memory thumbnail generation will use is slightly too low for your server. I have increased it from 2.5 to 3. This is basically a multiple of how inefficient the memory usage for PHP thumbnail generation is from the optimal. The attached file has $magic_factor=3; in it which you can try tweaking if it still won't work. I think it will now work though.
  2. You have set a huge thumbnail size and actually it is running out of memory on the image being made. It seems unlikely you'd set such a big thumbnail size, but it is a possibility because the memory errors are coming up in this part of the code I think actually it's just that there's barely enough memory to load the image and then it is just pushing it over the edge creating the destination image too.
  3. Your web host is one of the ones that has a deceiving PHP memory limit, where it claims to be turned off but is actually not, and therefore ocPortal can't test it's not going to exceed it. You can test this by typing this into OcCLE:

Code

:ini_set('memory_limit','-1'); echo ini_get('memory_limit');
. If it says "-1" then the server is lying to us ;).

This is all involving GD. You see, PHP has this memory limit setting (for good reason) so scripts can't use too much. When it has to work with images it has to load them up uncompressed, which uses relatively large amounts of RAM (width*height*4*fudgeFactor bytes). Obviously if you double the width of a square image you quadruple the RAM usage, so it jumps up fast.
I am actually going to try and implement support for presizing large image to something smaller using something else called ImageMagick, which should bypass PHP's memory limit.

Attachment
sources/images.php
» Download: images.php (22 Kb, 288 downloads so far)


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#67474
Avatar

Community saint

Chris Graham said

3) Your web host is one of the ones that has a deceiving PHP memory limit, where it claims to be turned off but is actually not, and therefore ocPortal can't test it's not going to exceed it. You can test this by typing this into OcCLE:

Code

:ini_set('memory_limit','-1'); echo ini_get('memory_limit');
. If it says "-1" then the server is lying to us ;).
I get "-1". What info/instructions can I give to my host to get them to fix this (hey, you never know, they may actually be willing to do something about it, they have been helpful so far with other issues/request)?

I'm not getting the error now, but I'm just trying to be prepared in case my memory allocation gets reduced in the future.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#67475
Avatar

If it returns "-1" and you're not getting memory errors after applying the fix here then the web host is fine.

The problem is if the memory limit is disableable like demonstrated on this line and then you still get memory errors from ocPortal screens that disable the memory limit.


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Item has a rating of 5 (Liked by Guest)  
Rating:
#67476
Avatar

This implements ImageMagick pre-resizing, so that even if ocPortal cannot disable the memory limit it may still be able to handle the images without showing an image-too-big error.

Attachment
sources/images.php
» Download: images.php (23 Kb, 281 downloads so far)


Become a fan of ocPortal on Facebook or add me as a friend. Add me on on Twitter.
Was I helpful?
  • If not, please let us know how we can do better (please try and propose any bigger ideas in such a way that they are fundable and scalable).
  • If so, please let others know about ocPortal whenever you see the opportunity.
  • If my reply is too Vulcan or expressed too much in business-strategy terms, and not particularly personal, I apologise. As a company & project maintainer, time is very limited to me, so usually when I write a reply I try and make it generic advice to all readers. I'm also naturally a joined-up thinker, so I always express my thoughts in combined business and technical terms. I recognise not everyone likes that, don't let my Vulcan-thinking stop you enjoying ocPortal on fun personal projects.
  • If my response can inspire a community tutorial, that's a great way of giving back to the project as a user.
Back to the top
 
Posted
Rating:
#67477
Avatar

Community saint

Chris Graham said

This implements ImageMagick pre-resizing, so that even if ocPortal cannot disable the memory limit it may still be able to handle the images without showing an image-too-big error.
Tested with an 8000x8000 jpeg and no image too large errors.

Do you have a Samsung Galaxy S / Galaxy S II ? If so, why not check out my ScreenFree FM Radio .
Back to the top
 
Posted
Rating:
#67485
Avatar

Fan in training

Chris Graham said

This implements ImageMagick pre-resizing, so that even if ocPortal cannot disable the memory limit it may still be able to handle the images without showing an image-too-big error.
I still keep getting errors :'(

Fatal error: Out of memory (allocated 72351744) (tried to allocate 5000 bytes) in /home/xxxxx/public_html/dev/sources/images.php on line 506

Chris Graham said

Your web host is one of the ones that has a deceiving PHP memory limit, where it claims to be turned off but is actually not, and therefore ocPortal can't test it's not going to exceed it. You can test this by typing this into OcCLE:
I get a return of -1 as well, and under php.ini through cPanel I can't edit "memory_limit".

Chris Graham said

If it returns "-1" and you're not getting memory errors after applying the fix here then the web host is fine.
So then this means since I'm still getting errors, that something is wrong on my web host? If so, could you please elaborate on why this is?

Chris Graham said

I am actually going to try and implement support for presizing large image to something smaller using something else called ImageMagick, which should bypass PHP's memory limit.
I think using ImageMagick would work out better than GD, as I use another CMS using ImageMagick on the same host, and have no problems with uploading and resizing images.

I want to thank you all again for the great support. :thumbs:
Back to the top
 
1 guests and 0 members have just viewed this: None
Control functions:

Quick reply   Expand