【发布时间】:2012-02-29 23:47:52
【问题描述】:
我正在尝试使用 XML::Twig 解析一个大型 xml 文件(大约 100,000 条记录),但 perl 解析失败并出现错误:
perl.exe - Application Error:
The instruction at "0x28086920" referenced memory at "0x00000004". The memory could not be "written"...
我读到XML::Twig 解析大型 xml 文件没有任何问题,但在我的情况下它失败并出现上述错误。
我的 .pl 文件有一个 forloop 代码,它可以旋转 100,000 次,如下所示:
foreach my $d1(@detailData) {
if ($d1->first_child('a')->getElementsByTagName('b')) {
$id= $d1->first_child('a')->first_child('x')->field('b');
}
....
.....
......
}
在 forloop 内部,我有大约 20 个如上所述的 if 循环。是不是内存问题?
谁能建议我如何克服这个记忆问题?
【问题讨论】:
-
您能说明
XML::Twig对象是如何被实例化和规范的吗? -
您似乎没有利用
XML::Twig的方法来限制内存使用,但就像 Zaid 暗示的那样,如果没有更多细节就不可能说出来。