Unfortunately, ->DESTROY is not a valid method for the MSFileReader software.

Its not supposed to be. DESTROY is perl name for the destructor, destructors usually do things like break circular references (parent/child/parent) ... things that leak memory; Re: cpu, memory, and permissions issues with Win32::OLE

Win32::OLE::Variant provides a DESTROY method http://cpansearch.perl.org/src/JDB/Win32-OLE-0.1712/OLE.xs

void DESTROY(self) SV *self PPCODE: { WINOLEVARIANTOBJECT *pVarObj = GetOleVariantObject(aTHX_ self); if (pVarObj) { RemoveFromObjectChain(aTHX_ (OBJECTHEADER*)pVarObj); ClearVariantObject(pVarObj); Safefree(pVarObj); } XSRETURN_EMPTY; }

I think I need a way to deallocate the SafeArray using perl (prefered) or a way to deallocate all memory associated with the MSFileReader.

undef does that -- if undef doesn't do it, something else is holding a reference ... say the dll itself

You have to find what MSFileReeader needs in the docs

Another thing to try http://search.cpan.org/grep?cpanid=JDB&release=Win32-OLE-0.1712&string=destroy&i=1&n=1&C=0 reveals SafeArrayDestroy is used internally. SafeArrayDestroy finds SafeArrayDestroy function (Automation) which says

Destroys an existing array descriptor and all of the data in the array. If objects are stored in the array, Release is called on each object in the array

So next you can try SafeArrayDestroy and Release

Also, from DESTROy above, there is ClearVariantObject, another one to try

See also http://search.cpan.org/dist/Win32-OLE/lib/Win32/OLE/NEWS.pod#Enumerate_all_Win32::OLE_objects

If none of these works, you'll have to mine the MSFileReeader docs ...

I am not sure how a foreach loop helps ...

Its a tip about perl syntax, because of your writing  my $woo; for( $woo=0; ... )


In reply to Re^3: Memory Leak using Win32::OLE::Variant for a SafeArray passed by Reference by Anonymous Monk
in thread Memory Leak using Win32::OLE::Variant for a SafeArray passed by Reference by jwn

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.