in reply to memory usage Spreadsheet::ParseExcel

Do the Monks have any idea how to free the memory used ...

If, as appears to be the case from the follow-on discussion, the problem is circular references preventing the data structures being destroyed, maybe running a depth-first function to free it might resolve the problem.

See how you get on with this:

sub recursiveFree { my $ref = shift; if( ref $ref eq 'ARRAY' ) { recursiveFree( $ref->[ $_ ] ) for 0 .. $#{ $ref }; } elsif( ref $ref eq 'HASH' ) { recursiveFree( $ref->{ $_ } ) for keys %{ $ref }; } elsif( ref $ref and ref $ref ne 'SCALAR' ) { warn "Unhandled reftype: ", ref( $ref ); } undef $ref; return; } recursiveFree( $xls );

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

Replies are listed 'Best First'.
Re^2: memory usage Spreadsheet::ParseExcel
by Anonymous Monk on May 14, 2012 at 13:59 UTC

    Tried it, no help, but great thanks anyway

    "the referenced object has been blessed into a package, then that package name is returned instead. I added Spreadsheet::ParseExcel::

    ::Workbook

    ::FmtDefault

    ::Format

    ::Font

    ::Worksheet

    as refs for Recursion. None seem to free memory and ::Worksheet warned on deep recursion and never came back up out of the stack

      "the referenced object has been blessed into a package, then that package name is returned instead.

      Switching from ref to Scalar::Util::reftype() would fix that.

      and ::Worksheet warned on deep recursion and never came back up out of the stack

      Using Scalar::Util::refaddr() with a %seen hash could prevent it recursing up its own bum.

      The code I posted was by way of example. Just a blind tweak of a depth-first recursive structure traversal I had kicking around.

      I'd have a go a making the above tweaks if I had a suitable example .xls file.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

        BrowserUk (Pope)

        here you go then pardner

        http://specialprojects.invisionzone.com/index.php?/topic/10-memory-usage-spreadsheetparseexcel/