dave <[EMAIL PROTECTED]> writes:

Hi Dave

> hmmm... doesn't appear to be pel or anything like that seems that my
> image resources aren't being completely freed or something and the
> memory usage accumulates, until it crashes

That's strange. I haven't tried processing multiple large images in a
single script with a memory limit before, so I haven't seen the bug

PEL don't know anything about file handles, image resources, or
similar stuff that would consume resources, so I don't see how it
should leak memory.

It does have a few static variables in Pel.php which could fill up.
I'm thinking of Pel::$exceptions which is an array of exceptions which
have been suppressed when parsing. Try calling Pel::clearExceptions()
once you are done with each image -- maybe that will help.

>> i'm using gd to resize my images, and pel to re-attach the exif
>> data after gd has finished but i've run into a problem with the
>> memory limit
>> i'm using php 5.2.0 on fedora core 4
>> pel is updated via svn from trunk


>> [...]
>> the offending code is [...]
>>       $origJpeg->loadFile($fullFilePath);

Good, this uses file_get_contents() to load the file in one big swoop.
The PHP manuals says that this is "the preferred way to read the
contents of a file into a string. It will use memory mapping
techniques if supported by your OS to enhance performance."

Unfortunately file_get_contents() doens't seem to work quite as good
as promised by the PHP documentation: see SF bug #1210126 where
someone suggested that PEL should read the data from the files as
needed. I thought that file_get_contents() would work that way since
it memory maps the file.

>>       $exif = $origJpeg->getExif();
>> [...]
>>         $newJpeg = null;
>>       }
>>       $origJpeg = null;

There might be a difference between assigning null to the variables
and calling unset() on them.

>> i am using imagedestroy, that is in another section of the code
>> that is not visible here

Okay good, that would have been my next question :-)

Martin Geisler  ---  <[EMAIL PROTECTED]>  ---  http://mgeisler.net

Read, write, create Exif data in PHP with PEL:       http://pel.sf.net
Take control of your webserver with PHP Shell:  http://phpshell.sf.net

Attachment: pgpoetslYQQPs.pgp
Description: PGP signature

Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
PEL-devel mailing list

Reply via email to