Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

threads eats up memory very fast ?

Status
Not open for further replies.

MoshiachNow

IS-IT--Management
Feb 6, 2002
1,851
IL
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 !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top