Subject: Re: samba on NetBSD 3.1, XP clients, and memory?
To: Stephen Borrill <netbsd@precedence.co.uk>
From: Carl Brewer <carl@bl.echidna.id.au>
List: netbsd-users
Date: 06/12/2007 13:27:53
Carl Brewer wrote:
> Stephen Borrill wrote:
> 
>> Yes, it's fixed in 4.0 and -current (though there has been the 
>> suggestion that there is a still a remaining memory leak somewhere).
>>
>> The way to easily spot the telldir problem is to look at the smbd 
>> memory usage while hitting F5 in a Windows Explorer window (Refresh) 
>> which is viewing a Samba share. It'll increase every time you hit F5.
> 
> Yep, we ran the app (AutoDESK) and it reported a failure when smbd (via
> ps) reported :
> 
> USER    PID %CPU %MEM    VSZ   RSS TTY   STAT STARTED     TIME COMMAND
> todd    318 17.1 25.8 133576 132996 ?     S     9:19AM  0:31.15 
> /usr/pkg/sbin/smbd -D
> 
> My guess is that that ran into the 128MB process limit by default in
> NetBSD 3.1.
> 
> Restarting samba 'fixed' it, as you'd expect.
> 

This is my short term hack to deal with it, if anyone wants it :

#!/usr/pkg/bin/perl

# $Id: smb_restarter.pl,v 1.2 2007/06/12 03:23:49 carl Exp carl $
use strict;

my $ps  = q(/bin/ps -auxww);
my $smb = q(smbd);
my $restarter   = q(/etc/rc.d/samba restart);
my $running     = 0;

#USER    PID %CPU %MEM    VSZ   RSS TTY   STAT STARTED     TIME COMMAND
#todd   1775  0.0  0.7   6308  3364 ?     S    12:50PM  0:02.11 
/usr/pkg/sbin/smbd -D

open (PS, "$ps |") or die "Can't exec $ps : $!\n";
while (<PS>) {
     chomp;
     my ($user, $pid, $cpu, $percentmem, $vsz, $rss, $tty, $stat, 
$started, $time, $command) = split(/\s+/, $_, 11);
     if ($command =~ /\/usr\/pkg\/sbin\/smbd -D/) {
         $running = 1;
         if ($vsz > 130000) {
             print STDERR "restarting Samba, vsz = ".$vsz."\n";
             system($restarter);
             close (PS);
             exit;
         }
     }
}
close (PS);

unless ($running) {
     print STDERR "restarting Samba\n";
     system($restarter);
}