HTML::TreeBuilder 中的内存泄漏
我有一些 Perl 代码:
use HTML::Parse;
use HTML::FormatText;
# ...
my $txtFormatter = HTML::FormatText->new();
while ( ... ) { # some condition
my $txt = # get from a file
my $html_tree = HTML::TreeBuilder->new_from_content($txt);
$txt = $txtFormatter->format($html_tree);
$html_tree->delete();
# write $txt to a file
}
我注意到 perl.exe
进程的大小稳步增加(在大约 200 万次循环迭代后达到 600 MB)。如果我取出 HTML::TreeBuilder
东西,它根本不会增加。我能做些什么来堵住这个漏洞吗?
I have some Perl code:
use HTML::Parse;
use HTML::FormatText;
# ...
my $txtFormatter = HTML::FormatText->new();
while ( ... ) { # some condition
my $txt = # get from a file
my $html_tree = HTML::TreeBuilder->new_from_content($txt);
$txt = $txtFormatter->format($html_tree);
$html_tree->delete();
# write $txt to a file
}
I noticed the perl.exe
process steadily increases in size (up to 600 MB after 2 million or so loop iterations). If I take out the HTML::TreeBuilder
stuff, it does not increase at all. Is there anything I can do to plug this leak?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我无法使用以下脚本复制此内容:
我让该脚本运行几分钟,并且内存使用量(在任务管理器中)保持在 7,200K 和 7,300K 之间。
I cannot replicate this with the following script:
I let this script run for minutes and the memory usage (in Task Manager) remained between 7,200K and 7,300K.