in reply to Re^3: Avoiding Memory Leaks with Win32::OLE (what leaks)
in thread Avoiding Memory Leaks with Win32::OLE
Yes, here are the numbers. When the test program posted in the original question is run with the outermost loop going from (0 .. 10000), the program gains between 4K and 10K/second in the Task manager.
What I modified. I added the code in OLE.xs to do a SafeArrayDestroy() on the SAFEARRAY* even if the variant has the VT_BYREF flag set. More specifically, immediately after the switch statement, but still inside the if() (at line 2333--maybe), in void ClearVariantObject(WINOLEVARIANTOBJECT *pVarObj), I added the following code,
/* 14-Oct-2015 WDJ Added to avoid memory leak of byref arrays +*/ if ( vt & VT_ARRAY ) /* this is an array byref */ { /* printf("WDJ doing additional SafeArrayDestroy\n"); */ SAFEARRAY *psa = *V_ARRAYREF(pVariant); if ( psa ) SafeArrayDestroy(psa); } /* printf("WDJ Calling VariantClear in addition to VariantInit +\n"); */ /* VariantClear(pVariant); */
The VariantClear(pVariant); that is commented out at the last line it likely not necessary, because the proper clean up was (hopefully) done manually above.
But since I did the above change on 14 Oct, I am working on updating the code to follow the plan I outlined in the original post, which adds a ByRef() method that will create a VT_BYREF version of the Variant so it can be passed to subroutines, etc. Stay tuned.
And yes, I e-mailed the original developer--no response yet. I'll ask around with my Python friends to see if they have done a similar thing.
|
|---|