B
bauer.mail
This is my first post here. I'll preface my question with this: I'm a
perl newb. I know enough to modify other peoples script, and I can
follow code if I stare at it enough, so bear with me if I dont
immediately understand your respone .
Here's the problem: I've got a 21MB AFP (IBM's Advanced Function
Presentation format) document that needs to be parsed. I have been
using Parse::AFP for smaller test files, and not noticed the insane
memory usage. When I attempt to load up a 21MB file, memory usage goes
through the roof (go to 1.3GB before my machine went haywire) when
iterating through the document even when I apply no further processing
to the data:
use Parse::AFP;
my $afp = Parse::AFP->new('data/bigone.afp', { lazy => 1 });
dumpit($afp);
sub dumpit {
my $obj = shift;
while (my $rec = $obj->next_member) {
my $type = substr(ref($rec), 12);
print $type."\n";
if ($obj->has_members) {
dumpit($obj);
}
}
}
Even for small test files (650kB) memory usage gets up to about 45 MB.
It seems to me that Parse::AFP is building an object hierarchy and
keeping it around even after I'm done processing those elements. Does
anyone have any experience with Parse::AFP? Any ideas to make it less
of a hog?
Thanks,
Scott Bauer
perl newb. I know enough to modify other peoples script, and I can
follow code if I stare at it enough, so bear with me if I dont
immediately understand your respone .
Here's the problem: I've got a 21MB AFP (IBM's Advanced Function
Presentation format) document that needs to be parsed. I have been
using Parse::AFP for smaller test files, and not noticed the insane
memory usage. When I attempt to load up a 21MB file, memory usage goes
through the roof (go to 1.3GB before my machine went haywire) when
iterating through the document even when I apply no further processing
to the data:
use Parse::AFP;
my $afp = Parse::AFP->new('data/bigone.afp', { lazy => 1 });
dumpit($afp);
sub dumpit {
my $obj = shift;
while (my $rec = $obj->next_member) {
my $type = substr(ref($rec), 12);
print $type."\n";
if ($obj->has_members) {
dumpit($obj);
}
}
}
Even for small test files (650kB) memory usage gets up to about 45 MB.
It seems to me that Parse::AFP is building an object hierarchy and
keeping it around even after I'm done processing those elements. Does
anyone have any experience with Parse::AFP? Any ideas to make it less
of a hog?
Thanks,
Scott Bauer