Re: Win32::Perms Dump function Memory Leak
by Dan Richfield other posts by this author
Mar 3 2006 1:04PM messages near this date
view in the new Beta List Site
RE: Looking for true number of processors in a remote server
|
GetMessageText does not work for "new" event logs
I have posted several times before regarding this issue. I have made more
progress now as I was finally able to compile PERMS.DLL from the source
(ftp://www.roth.net/pub/ntperl/perms/20020605/source/Perms_Source.Zip). Now
that I have been able to do that, I can actually work on the actual problem
which is a memory leak in the XS_WIN32__Perms_Dump function in Perms.CPP.
I have a test script that creates a Win32::Perms object, loops 1,000,000
times, changing the path on each iteration and doing a Dump into an array.
That code is here:
use Win32::Perms;
$DirFileObj = new Win32::Perms("C:/test") ||
die(Win32::FormatMessage(Win32::GetLastError()));
for ($i = 0; $i <= 1000000; $i++) {
$DirFileObj-> Path("C:/test") ||
die(Win32::FormatMessage(Win32::GetLastError()));
$DirFileObj-> Dump(\@AclInfo) ||
die(Win32::FormatMessage(Win32::GetLastError()));
foreach $AceInfo (@AclInfo) {
foreach $AceName (keys %$AceInfo) {
print "$AceName: $AceInfo-> {$AceName}\n";
}
print "\n\n";
}
}
I know it's changing the path to the same directory on each iteration, but
it doesn't matter, this is only for testing.
The first thing I tried was to comment out all the code in the
XS_WIN32__Perms_Dump. Obviously, my script produced no output because the
Dump returned nothing into @AclInfo, but memory usage did not increase past
~3MB for Perl.exe. Please keep in mind that when using the original code in
the XS function, memory usage on Perl.exe increases exponentially. I then
added the following code into the now empty XS_WIN32__Perms_Dump function:
XS(XS_WIN32__Perms_Dump)
{
AV *pAv = NULL;
pAv = newAV();
av_clear( pAv );
av_undef( pAv );
pAv = NULL;
}
All this code does it define a new array called pAv and then it attempts to
clear that array from memory. Info on the av_clear and av_undef perlapi
functions can be found here:
http://perldoc.perl.org/perlapi.html
I have also tried this function with only av_clear, and only av_undef
seperately. I also understand that av_clear clears the array but does not
clear memory, but av_undef does supposedly clears both. When executing this
from my test script, memory on Perl.exe is not cleared and increases
exponentially.
So, to sum this all up. Why are these functions to free up the memory this
EMPTY array uses not working properly?
Thanks,
Dan
_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@[...].com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
|