looks like memory-leak in perlmagick-function Statistics()
Posted: 2014-07-01T10:39:04-07:00
I have to analyse some thousand pictures. So I wrote a Perl-script and use the perlmagick-function "Statistics()". Running this script the usage of memory grows permanently until the Computer was out of memory. Debugging the script I notice that every time I use the perlmagick-function "Statistics()" the usage of memory grows. I do not find a workaround to free the memory. I checked and replicate this behavior on Win-XP(32bit) and Win7(64bit) using the current version of perlmagick. So at this moment I would say there is a memory-leak in this function.
Does anyone has an Idea for a workaround or how to fix the problem?
For testing and demonstrating I wrote this lite Script :
Does anyone has an Idea for a workaround or how to fix the problem?
For testing and demonstrating I wrote this lite Script :
Code: Select all
#!/usr/bin/perl -w
use strict;
use warnings;
use Image::Magick;
my $source_URI=”any_picture” ; # chose a picture you want
my $source_image= Image::Magick->new;
my $Returnvalue = $source_image->Read($source_URI);
my $analysis_area = "10x10+100+100";
my @stat ;
for(my $I=0; $I <5000000; $I++){
print("Counter = $I \n");
my $analysis_image = Image::Magick->new;
$analysis_image = $source_image->Clone();
$Returnvalue = $analysis_image->Crop(geometry=>$analysis_area);
$analysis_image->Statistics(); # here is the problem
@stat = (); # trying to free the memory
$analysis_image=(); # trying to free the memory
undef $analysis_image; # trying to free the memory
}
undef @stat;
undef $source_image;