Problems with Parse::AFP

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
 
J

Jeff Stampes

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);
}
}
}

Without knowing anything about the Parse::AFP class, I wonder why this
is a recursive routine? Wouldn't this do what you want without the
recursion?

~Jeff
 
B

bauer.mail

The recursion only occurrs when when the element that is currently
being processed has child elements. Those elements may have children
and so on... The data I'm after is a few levels into the heirarchy.
After looking through some more of the samples, it appears that there
may be another way to pull out the information I'm looking for, but
I'll have to keep hacking at it.

Scott
 
B

bauer.mail

The memory jumps up as soon as I call "$obj->next_member", which is an
instance method off of Parse::Binary, if that helps any.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,053
Latest member
BrodieSola

Latest Threads

Top