Hi Gurus :c) ,

I've got an app that runs as a service off a W2K box.
Basically, what it does is, given an initial list of NT domains, it
retrieves all the servers from those domains.
Then I feed that list of servers to two subroutines.
Subroutine 01  gets the number of open files for the server.
Subroutine 02 gets the number of connections opened on server.
Then with that info, I log it to RRD.
The service is working, gets the correct information, but.....  subroutine
02 has some sort of memory leak that I can't find a way to plug up.
After a week or so of the service being up, it has allocated something of
the order of 300MB of memory or more. First time I noticed it, it managed
to gobble up all the available virtual memory.
I've been toying with tie and untie in the hope it might work... so far no
luck.
Somewhere I read that the hash created by Lanman needs to be destroyed
before calling it again, 'cause Lanman would just keep adding to it each
time its called. So, I believe, the cause of my problems.
Here's the subroutine....

#--------------------------------------------------------
sub Pega_Sessoes {
   my ($Servidor) = @_;
   my ($TotSess, @shares, $share, %conns, $conn, @conns, $key, $resources,
$href,%share);
   undef @shares;
   undef %share;
   undef %{$share};
   undef $share;
#   if (Win32::NetResource::GetSharedResources($resources,
RESOURCETYPE_ANY,
#                 { RemoteName => "\\\\" . $Servidor })) {
#    foreach my $href (@$resources) {
#        print "$Servidor-----\n";
#        foreach(keys %$href) { print "$_: $href->{$_}\n"; }
#    }
#    }
#   else {
#    my $err;
#    GetError($err);
#    warn Win32::FormatMessage($err);
#   }
    tie %{$share}, 'Win32::Lanman';
    if(Win32::Lanman::NetShareEnum($Servidor, [EMAIL PROTECTED]))  {
       $TotSess = 0;
       foreach $share (@shares)  {
          $TotSess += $share->{'current_uses'};
#          undef %{$share} ;
#          undef $share;
#          undef %share;
           untie %{$share};
       }
   }
   else {
       $TotSess = -1;
       ReportWarn ("Nao pude pegar conexoes do $Servidor: " .
Win32::FormatMessage(Win32::Lanman::GetLastError()));
   }
   undef @shares;
   undef %share;
   undef %{$share};
   undef $share;
   return ($TotSess);
}

Any info would be greatly appreciated!

Thanks!

Cheers,
/LG

/Luiz George Ramsey Barreiros
Analista Assistente de Informatica
GEPRO NRT 1-RJ/SETAR
Banco do Brasil S.A.


_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to