MoshiachNow
IS-IT--Management
HI,
I'm using "threads"and it seems that it eats up all my memory very fast.
Sub "threadme" call creates thread calling sub "allPerf".
An external loop runs "threadme" sub every 2 sec,eating up another 1-MB of memory ...
What should I have been cleaning/exiting that I do not ?
thanks
=================================
use threads;
sub threadMe {
$station = shift;
$thr->{$station} = threads->create(\&allPerf);
$thr->{$station}->detach();
}
sub allPerf {
#print STDOUT "====station=$station\n";
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$station\\root\\CIMV2") or warn "WMI connection failed on $station \n";
my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (sort( SortProcs ( in( $colItems ) ) ) ) {
if ($objItem->{'Name'} =~ /RipNT|perl|Prepare|RTPService|StreamLineManager|$svchost/) {
print FINAL "$objItem->{'IDProcess'}\t$objItem->{'Name'}\t$objItem->{'PercentUserTime'}\n";
}
}
threads->exit() if threads->can('exit'); # Thread friendly exit(status);
}
Long live king Moshiach !
I'm using "threads"and it seems that it eats up all my memory very fast.
Sub "threadme" call creates thread calling sub "allPerf".
An external loop runs "threadme" sub every 2 sec,eating up another 1-MB of memory ...
What should I have been cleaning/exiting that I do not ?
thanks
=================================
use threads;
sub threadMe {
$station = shift;
$thr->{$station} = threads->create(\&allPerf);
$thr->{$station}->detach();
}
sub allPerf {
#print STDOUT "====station=$station\n";
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
my $objWMIService = Win32::OLE->GetObject("winmgmts:\\\\$station\\root\\CIMV2") or warn "WMI connection failed on $station \n";
my $colItems = $objWMIService->ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (sort( SortProcs ( in( $colItems ) ) ) ) {
if ($objItem->{'Name'} =~ /RipNT|perl|Prepare|RTPService|StreamLineManager|$svchost/) {
print FINAL "$objItem->{'IDProcess'}\t$objItem->{'Name'}\t$objItem->{'PercentUserTime'}\n";
}
}
threads->exit() if threads->can('exit'); # Thread friendly exit(status);
}
Long live king Moshiach !