Welcome Guest, Not a member yet? Register   Sign In
Memory Limit Help!
#3

[eluser]tjtyrrell[/eluser]
So I start with:
Code:
$import_images_folder = realpath(dirname(__FILE__) . '/../../../import/' . $old_user->user_directory . '/images/');
(ugly I know, and there are better ./ options, but I was having some issues and this worked)
Then:
Code:
$import_images = get_filenames($import_images_folder, true);

Then I loop through the array
Code:
foreach( $import_images as $image ) {
// Manipulate the image
}

The code is properly accessing images and using GD2 to resize/copy them to their new destination. After a successful copy/resize, it adds the image to the image library database table and then loops through to the next image.

The only thing I can conceive is old image handles aren't being terminated (the gd2 version of fclose) and thus not freeing up memory. My code doesn't process the next image until the last image is complete (unless I am not understanding how the GD2 library works, which is highly possible).

Also, a new update. I execute my import scripts with memory_limit=-1 (infinite) and I get this error:
Quote:Fatal error: Maximum execution time of 300 seconds exceeded in /var/www/{{folder}}/system/libraries/Image_lib.php on line 522

This happens 6 minutes after I start the script. So does that mean I am not ending the first image manipulation and starting a bunch of others at the same time?

I had assumed $this->image_lib->resize() starts and completes (or errors on) the process before continuing with the rest of the import script (thus terminating the file handle and freeing up memory).

(side note: the version of CI I am using has this for line 522:
$copy($dst_img, $src_img, 0, 0, $this->x_axis, $this->y_axis, $this->width, $this->height, $this->orig_width, $this->orig_height);

$copy in this instance is 'imagecopyresampled' for the gd2 library.


Messages In This Thread
Memory Limit Help! - by El Forum - 12-11-2013, 04:57 AM
Memory Limit Help! - by El Forum - 12-11-2013, 11:19 AM
Memory Limit Help! - by El Forum - 12-11-2013, 12:54 PM
Memory Limit Help! - by El Forum - 12-11-2013, 01:05 PM
Memory Limit Help! - by El Forum - 12-11-2013, 01:08 PM
Memory Limit Help! - by El Forum - 12-11-2013, 01:27 PM
Memory Limit Help! - by El Forum - 12-11-2013, 01:53 PM
Memory Limit Help! - by El Forum - 12-11-2013, 02:24 PM
Memory Limit Help! - by El Forum - 12-11-2013, 02:42 PM



Theme © iAndrew 2016 - Forum software by © MyBB