Re: perlmagick and leaking memory

2001-08-25 Thread Joshua Chamas

Jon Molin wrote:
 
 Hi list,
 
 I've done a scripts that builds an calender and colours the days with
 different colours depending on the status of the day. I've got 6 colours
 and one to just fill out so the month starts with the correct day, ie
 i've got 6 * 31 + 1 = 187 images and each is about 70 bytes so a
 calender is 6 times 7 of these little sqaures, about 3k.
 
 Now this little script handling this tiny amount of data runs amok and
 grows and grows untill i restart apache brutaly, I guess I've done
 something very wrong but I can't figure out what, nor can I find any
 info about this. Here's what the program looks like:
 

Generally, I am not surprised when finding memory leaks in XYZ
module.  The code in the email looked fine, so I would suspect
Image::Magick having the leak.  To prove this better, you might
take the code out of the mod_perl request, and run it through a 
test of 1000 iterations in a command line script, and report the 
problem to the author of Image::Magick.

So, without waiting for a Image::Magick fix, you can make
memory leaks less painful by setting MaxRequestPerChild lower, say
to 100 or by using a solution like Apache::SizeLimit to kill a child 
process when it uses too much RAM ( unshared RAM on Linux too )

--Josh

_
Joshua Chamas   Chamas Enterprises Inc.
NodeWorks Founder   Huntington Beach, CA  USA 
http://www.nodeworks.com1-714-625-4051



perlmagick and leaking memory

2001-08-21 Thread Jon Molin

Hi list,

I've done a scripts that builds an calender and colours the days with
different colours depending on the status of the day. I've got 6 colours
and one to just fill out so the month starts with the correct day, ie
i've got 6 * 31 + 1 = 187 images and each is about 70 bytes so a
calender is 6 times 7 of these little sqaures, about 3k. 

Now this little script handling this tiny amount of data runs amok and
grows and grows untill i restart apache brutaly, I guess I've done
something very wrong but I can't figure out what, nor can I find any
info about this. Here's what the program looks like:


my $image_obj = Image::Magick-new;
my $images = $image_obj-Read (@days); # an array with 49 filnames
my $montage = $image_obj-Montage (
   mode = 'Concatenate',
   background ='#ff',
   tile = '7x7',
   frame = '1x1',
   gravity = 'center',
   );

$montage-Crop ('138x118'); #fixing the size

print Content-Type: image/gif\n\n ;
$montage-Write();# the image doesn't come out out unless i use Write
before
print $montage-ImageToBlob();

undef $montage;
undef $images;
undef $image_obj;


Anyone see any obvious mistakes?

I also tried putting this before the undef's but it didn't do any
difference:
for (my $i = 0; $i = 48; $i++)
{
undef $image_obj-[$i];
}

/Jon