- 论坛徽章:
- 0
|
本帖最后由 brant_chen 于 2010-08-22 00:42 编辑
我用的是XML::Simple。
我发现,我用(xml文件有2MB左右)
$xml_file_content = XMLin($xml_name);
后,内存涨了很多,我就把要读的内容存到一个hash后,然后置
$xml_file_content = undef;
sleep 10; # 留点时间观察内存释放没有
结果发现内存灭有释放呢?
请问怎么释放啊?
谢谢!- #!/usr/bin/perl
- use XML::Simple;
- use Data::Dumper;
- my %table;
- my $xml_file1="I18n.tst";
- my $xml_file2="I18n2.tst";
- my $xml_name="List.xml";
- my $xml_file_content=undef;
- $xml_file_content = XMLin($xml_name);
- $table{$xml_file1}=[] unless exists $table{$xml_file1};
- $table{$xml_file2}=[] unless exists $table{$xml_file2};
- foreach my $key (keys (%{$xml_file_content->{$xml_file1}->{'en_iso-8859-1'}})){
- print "test1:$key". "\n";
- print "test12:$xml_file_content->{$xml_file1}->{'en_iso-8859-1'}->{$key}\n";
- push @{$table{$xml_file1}}, "[".$key."]".$xml_file_content->{$xml_file1}->{'en_iso-8859-1'}->{$key};
- }
- foreach my $key (keys (%{$xml_file_content->{$xml_file2}->{'en_iso-8859-1'}})){
- print "test2:$key". "\n";
- print "test22:$xml_file_content->{$xml_file2}->{'en_iso-8859-1'}->{$key}\n";
- push @{$table{$xml_file2}}, "[".$key."]".$xml_file_content->{$xml_file2}->{'en_iso-8859-1'}->{$key};
- }
- $xml_file_content=undef;
- foreach $xml_file (sort keys %table) {
- print "\n$xml_file:\n";
- my @cities = @{$table{$xml_file}};
- print "test3:" . join ', ', sort @cities;
- print ".\n";
- }
- sleep 10;
- exit 0;
复制代码 |
|