davis has asked for the wisdom of the Perl Monks concerning the following question:

I've been using the Spreadsheet::ParseExcel module to extract information out of ~2000 excel files, and I've found what I believe to be a memory leak in that module. Code that (I believe) demonstrates the problem:

#!/usr/bin/perl use warnings; use strict; use Spreadsheet::ParseExcel; use Devel::Leak; my $handle; my $num_vars = Devel::Leak::NoteSV($handle); { my $filename = "9000.xls"; my $oExcel = new Spreadsheet::ParseExcel; die "No excel obj\n" unless $oExcel; my $oBook = $oExcel->Parse($filename); unless($oBook) { die "Parsing of file $filename failed: $!\n"; } } my $new_num_vars = Devel::Leak::CheckSV($handle);

Because that code prints out a lot of information about variables (example below with apologies for duplicated code tags), I believe there's a memory leak in Spreadsheet::ParseExcel. If I change the code above to a simple for() loop within the same naked block, then I don't get any output.

new 0x8152d54 : SV = PVGV(0x852b8a0) at 0x8152d54 REFCNT = 1 FLAGS = (GMG,SMG,MULTI) IV = 0 NV = 0 MAGIC = 0x852b910 MG_VIRTUAL = &PL_vtbl_glob MG_TYPE = PERL_MAGIC_glob(*) MG_OBJ = 0x8152d54 NAME = "DESTROY" NAMELEN = 7 GvSTASH = 0x8169050 "Exporter" GP = 0x852b8d8 SV = 0x8152d90 REFCNT = 1 IO = 0x0 FORM = 0x0 AV = 0x0 HV = 0x0 CV = 0x0 CVGEN = 0x0 GPFLAGS = 0x0 LINE = 290 FILE = "/usr/lib/perl5/site_perl/5.8.0/Spreadsheet/ParseExcel.pm" FLAGS = 0x2 EGV = 0x8152d54 "DESTROY"

My actual questions:

  1. Have I found a memory leak?
  2. What do I do about it if I have?
  3. This item inserted because I thought I had another question, and I don't like lists with two entries
Update: I forgot to mention that I am using the latest version (0.2602) of Spreadsheet::ParseExcel


davis
It's not easy to juggle a pregnant wife and a troubled child, but somehow I managed to fit in eight hours of TV a day.

Replies are listed 'Best First'.
Re: Have I found a memory leak?
by dragonchild (Archbishop) on Dec 12, 2003 at 13:35 UTC
    1. Very probably. The code is somewhat hairy and the author proclaims it to be "alpha" quality.
    2. Find the leak, write a patch, and submit it to the author. However, the author may not be actively maintaining the module as the last update was July 15, 2002. If the author is not maintaining, take it over!
    3. I don't like lists with 2 elements, either. :-)

    Update: After glancing through the source, try removing all references to Exporter in the code. That might be the problem. (Spreadsheet::ParseExcel doesn't actually use any Exporter functionality, from what I remember, though I could be wrong.)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.