4

I am trying parse a large xml file (around 100,000 records) using XML::Twig but perl parsing fails with error:

perl.exe - Application Error: 
The instruction at "0x28086920" referenced memory at "0x00000004". The memory could not be "written"...

I read that XML::Twig parses large xml files without any issues, but in my case it fails with the above error.

My .pl file has a forloop code that rotates 100,000 times as below:

foreach my $d1(@detailData)   {
    if ($d1->first_child('a')->getElementsByTagName('b')) {
        $id= $d1->first_child('a')->first_child('x')->field('b');
    }
    ....
    .....
    ......

}

Inside forloop I have around 20 if loops as above. Is it causing the memory issues?

Can anyone suggest me how to overcome this memory issues?

4

1 回答 1

6

在谷歌搜索之后,perl "The memory could not be written"我猜想问题来自于在内存中一次加载文件,例如参见http://www.perlmonks.org/?node_id=457265或(不太可能)来自混合使用不同编译器编译的模块(例如,使用带有 Cygwin perl 的 Activestate 包,请参阅http://cygwin.com/ml/cygwin/2006-12/msg00798.html)。

对于 XML::Twig 处理大文件,您需要告诉它在哪个级别处理文件的某些部分(通常通过定义处理子树的处理程序,然后丢弃它),请参阅模块的文档。

于 2012-01-31T11:35:34.073 回答