CPAN::Forum
HTML-TableExtract - possible memory leak?
| Posted on Sun Feb 11 02:55:05 2007 by mnguyen |
| possible memory leak? |
|
I am having a problem with the package. Everytime I create an instance of the class and and then destroy it, it doesn't seem to be cleaned up when I watch Task Manager. I am parsing 1000+ html pages. What ends up happening is that my machine's memory eventually gets eaten up and the process dies due to memory overflow. Am I not destroying the instance properly? I've attached sample code of what I am using that causes this behavior. If you watch the memory usage while the program runs, you will see it rise pretty quickly.
Any help would be appreciated.
## loop through 1000+ html files
foreach ( @HTMLPAGES ) {
my $tableRef = &getTableById( $_, 'tableid');
print $tableRef-> as_HTML;
$tableRef-> delete;
}
sub getTableById {
my ( $html_string, $tableKey ) = @_;
my $te = HTML::TableExtract->new( attribs => { id => $tableKey } );
$te->parse($html_string);
$te-> eof; ## is this necessary?
my $retVal = $te->first_table_found()->tree;
$te -> delete;
return \$retVal;
}
Thanks,
michael
|
| Write a response |
(3)
]