Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Spreadsheet::ParseExcel - Out of memory error
I have a piece of code that needs to open 31 excel spreadsheets, find
out the row count for each.  When it runs it gets about 10 files in
and crashes with an Out of memory error.

Here is an excerpt from the code:
my $oBook;
my $oWks;
my ($iR, $iC, $oWkS, $oWkC);
foreach $hashEntry ( @LOGS )
{

my ( $localfile)        =3D $hashEntry->{name};
my ( $err_msg )         =3D "";           # error message variable


my $cmd                 =3D "";

#
# Get row count of each file, to generate results file
#
$oBook =3D new Spreadsheet::ParseExcel::Workbook->Parse($localfile);
$oWkS =3D ${$oBook->{Worksheet}}[0];

print "------ SHEET: ".$oWkS->{Name}. "\n";
print "Row: ".$oWkS->{MinRow}." v ".$oWkS->{MaxRow}."\n";
$resultMessage.=3Dbasename($localfile).",".$oWkS->{MaxRow}."\n";
}


Is there anything I can do to 'dump' the memory.  My initial feeling
is something in ParseExcel, or one of the dependencies isn't playing
nice...or rather I am not letting it play nice through some inaction
or action on my part.

Anyone have some ideas on dealing with this memory problem?

Cheers,
Craig

Report this thread to moderator Post Follow-up to this message
Old Post
Craig Moynes
04-27-05 08:56 AM


RE: Spreadsheet::ParseExcel - Out of memory error
Craig Moynes wrote:
> Hi All,
> I am using the spreadsheet::parseexcel module to open up a series (31)
> spreadsheets and grab the row counts.
>=20
> Here is an excerpt with the ParseExcel Code.
>=20
> my $oBook;
> my $oWks;
> foreach $hashEntry ( @LOGS )
> {
>=20
>          my ( $localfile)        =3D $hashEntry->{name};
>          my ( $err_msg )         =3D "";           # error message
> variable=20
>=20
>=20
>          my $cmd                 =3D "";
>=20
>          #
>          # Get row count of each file, to generate results file
>          #
>          $oBook =3D new
>          Spreadsheet::ParseExcel::Workbook->Parse($localfile); my
>          ($iR, $iC, $oWkS, $oWkC); $oWkS =3D ${$oBook->{Worksheet}}[0];
>=20
>          print "------ SHEET: ".$oWkS->{Name}. "\n";
>          print "Row: ".$oWkS->{MinRow}." v ".$oWkS->{MaxRow}."\n";
>        =20
> $resultMessage.=3Dbasename($localfile).",".$oWkS->{MaxRow}."\n"; }
>=20
> The problem I am running into is after 10 files (in testing all 31
> files are the same source file with different names), and then I get
> an out of memory error.  Anyone have any idea how I can clean out the
> memory.  I have a feeling it might be some autocaching or something
> not getting cleaned up within ParseExcel.
>=20
No where do I see you closing or destroying the existing data structure.  =
I was working on similiar item and only wanted the first row and last colum=
n, but it was loading the whole file in. Forunately one of the Perl gurus p=
rovided a work around, but to get the last row of each Excel file will requ=
ire the loading of the whole file, unless some guru has a work around that =
cheats loading the whole file.

Wags ;)
> Cheers,
>     Craig



 ****************************************
***************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
 ****************************************
***************


Report this thread to moderator Post Follow-up to this message
Old Post
Wagner, David --- Senior Programmer Analyst --- WG
04-27-05 08:56 AM


Re: Spreadsheet::ParseExcel - Out of memory error
On 4/26/05, Wagner, David --- Senior Programmer Analyst --- WGO
<David.Wagner@freight.fedex.com> wrote:
> Craig Moynes wrote: 
>         No where do I see you closing or destroying the existing data str=
ucture.  I was >working on similiar item and only wanted the first row and =
last column, but it was loading >the whole file in. Forunately one of the P=
erl gurus provided a work around, but to get the >last row of each Excel fi=
le will require the loading of the whole file, unless some guru has a >work=
around that cheats loading the whole file.

I thought that by defining the oBook and oWks variables outside the
for loop, that the memory for an old object referenced in those
variables would be garbage collected when reassigned.  Can you paste a
code sample for the garbage collection stuff that the gurus supplied
you with.

Cheers,
Craig

Report this thread to moderator Post Follow-up to this message
Old Post
Craig Moynes
04-27-05 08:56 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:32 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.