Weird problem with devstat interface

Fred Gilham gilham at csl.sri.com
Tue Jun 28 17:49:27 GMT 2005


Hello,

There's a program called xsysinfo in the ports collection which
currently seems to be just about the only working system status program
for FreeBSD 5 or 6.  Unfortunately the current version seems to have a
memory leak.  This memory leak isn't related to the program itself but
to the devstat interface.  By this I mean that it's not caused by any
malloc or free that the program's code does.  If you run this program
for a few days it will grow to hundreds of megabytes in size and
eventually exhaust memory.  It does this under FBSD 5 & 6 but not 4
(which of course uses a different interface to the kernel stats).

The program will not do this if you use the -nodisk option telling it
not to track disk statistics, which means that the problem gets narrowed
down to the devstat stuff that is used to keep track of disk transfers.

I have been able to get the program to stop doing this by changing the
calls to

devstat_checkversion()
devstat_getnumdevs()
devstat_getdevs()

so they don't use the kvm interface but the sysctl interface
(i.e. passing NULL instead of a file descriptor to /dev/kvm).


It seems like there's either a bug in the port or some weirdness in the
devstat interface, so I thought I'd post about it to see if anyone knew
what was going on.

-- 
Fred Gilham                                        gilham at csl.sri.com
The PTPL (People's Trotskyist Programming League) believes that
hackers are elitist and that all software should be created by the
masses flailing away at millions of keyboards.  I didn't have the
heart to tell them that this has already been tried and the result is
called Linux.


More information about the freebsd-current mailing list