Welcome Guest, Not a member yet? Register   Sign In
Changing memory size on a single page in CodeIgniter
#1

[eluser]See64[/eluser]
I'm playing around with the image manipulation class, and I'm running into the well known "Allowed memory size of 8388608 bytes exhausted..." error. I was wondering what the best way to temprarily change this value is. I'm only resizing an image when the visitor uploads one that's too big, so setting the maximum to 32MB for *every* page seems overkill.

What is the best way to do this in CodeIgniter for *just* the upload-page?
#2

[eluser]coolfactor[/eluser]
PHP 5's default memory_size limit is 128MB. I would recommend upgrading to PHP5 for the improved memory management or not worry about the 32MB limit you currently have.

To answer your question, put this into the function where it's needed:
Code:
ini_set('memory_limit', '32M');

That will change the memory limit temporarily.
#3

[eluser]See64[/eluser]
[quote author="coolfactor" date="1185754396"]PHP 5's default memory_size limit is 128MB. I would recommend upgrading to PHP5 for the improved memory management or not worry about the 32MB limit you currently have.

To answer your question, put this into the function where it's needed:
Code:
ini_set('memory_limit', '32M');

That will change the memory limit temporarily.[/quote]

Thanks for your reply! I'm actually running PHP5 (through AppServ on Windows)but it still gave the error. I will be using a live server with PHP5, I'll check if that has the bigger memory limit.

Is it necessary to put the memory_limit back to default after resizing?
#4

[eluser]coolfactor[/eluser]
[quote author="See64" date="1185764612"]Is it necessary to put the memory_limit back to default after resizing?[/quote]

No. Setting it using ini_set() only changes it temporarily for that one page request. It's back to its default for the next page load.




Theme © iAndrew 2016 - Forum software by © MyBB