> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On > Behalf Of Paul Sobey > Sent: 20 March 2006 11:50 > To: perl-win32-users@listserv.ActiveState.com > Subject: Win32::OLE - Mem Leak? > > I'm trying to debug a slow memory leak in a service I have written to > monitor performance counters on my servers. The service > queries several > wmi every 5 seconds, and exhibits a very slow leak, such that > processes > grow to a 100MB in size after a few weeks.
<snip> Thanks to the excellent Jan Dubois, who has not only confirmed the leak (in the Win32::OLE _in_ function), but also provided a workaround. Replacing: my $ResultSet = $WMI->ExecQuery($SQL); foreach my $result ( in $ResultSet) { foreach my $attribute ( @{ $wmi_queries->{$class} } ) { my $answer = $result->{$attribute}; } } with: my $result_count = $ResultSet->{count}; my $enum = Win32::OLE::Enum->new($ResultSet); # print "Got $result_count items in set\n"; for ( 1 .. $result_count ) { my $result = $enum->Next; foreach my $attribute ( @{ $wmi_queries->{$class} } ) { my $answer = $result->{$attribute}; } } ## end for ( 1 .. $result_count) fixes the problem, ie getting a count of attributes returned, and iterating across them explicitly with the Win32::OLE::Enum object's Next command. Fixed code attached, and works like a charm. Win32::OLE will hopefully be fixed in the release of libwin32. Thanks again Jan - you've saved my bacon. P. ***************************************************************** Gloucester Research Limited believes the information provided herein is reliable. While every care has been taken to ensure accuracy, the information is furnished to the recipients with no warranty as to the completeness and accuracy of its contents and on condition that any errors or omissions shall not be made the basis for any claim, demand or cause for action. The information in this email is intended only for the named recipient. If you are not the intended recipient please notify us immediately and do not copy, distribute or take action based on this e-mail. Gloucester Research Limited, 5th Floor, Whittington House, 19-30 Alfred Place, London WC1E 7EA *****************************************************************
wmi.pl
Description: wmi.pl
_______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs