in reply to Re: Memory Leak HTML::FormatText
in thread Memory Leak HTML::FormatText
Thank you for your reply.
The first part of the code is at the highest level of the program, so @input is used throughout the while loop, which basically is the whole program. The first part just opens a file with website-addresses which get loaded into @input and then the loop cycles through them.
In any case, I have now changed the code to the following:
use warnings; use strict; use diagnostics; use HTML::FormatText; use HTML::TreeBuilder 5 - weak; open INPUT, "< D:/websitelocations.txt" or die "Problem: $!"; my @INPUT=<INPUT>; close INPUT; while (@INPUT) { my $input=shift(@INPUT); chomp $input; print $input; my $content=HTML::FormatText->format_file($input, leftmargin => 0, ri +ghtmargin => 50); # followed by regular expressions, the results of which are saved pri +nted into a new file, all of this is currently disabled }
The memory leak is still there though. It runs out of memory after about 3000 files, but I have more than 28 000.
I still think it has something to do with HTML::FormatText. I read elsewhere that this calls HTML::Treebuilder which in the past has caused memory leaks when the object was not explicitly deleted. I added now
use HTML::TreeBuilder 5 - weak;which should take care of it according to CPAN documentation on HTML::TreeBuilder. However, apparently it does not. I also tried to add explicit calls to the delete function:
$content->delete(new)As well as
$input->delete(new)But this just gives me an error message: can't locate object message
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Memory Leak HTML::FormatText
by Anonymous Monk on Sep 16, 2013 at 08:14 UTC | |
by PerlNovice999 (Novice) on Sep 16, 2013 at 09:23 UTC | |
by PerlNovice999 (Novice) on Sep 16, 2013 at 09:17 UTC | |
by Anonymous Monk on Sep 16, 2013 at 10:14 UTC | |
by PerlNovice999 (Novice) on Sep 18, 2013 at 12:25 UTC | |
by Anonymous Monk on Sep 18, 2013 at 13:27 UTC | |
by PerlNovice999 (Novice) on Sep 18, 2013 at 13:34 UTC | |
by Anonymous Monk on Sep 18, 2013 at 14:01 UTC |