Tracking down memory leaks
cswiger at mac.com
Wed Mar 21 20:56:16 UTC 2007
On Mar 21, 2007, at 1:17 PM, Don O'Neil wrote:
> My setup seems to have a memory leak of some kind and I'm not sure
> how to
> track it down....
> When I first start up the system and all the processes start the
> machine has
> 1GB in free memory... After running for 20-30 minutes the free
> memory drops
> to somewhere around 20MB... The longer it runs, the more it chews
> up free
> memory until it eventually kernel panics and then reboots and the
> starts all over again.
> I originally thought the reboot was from bad RAM, so I swapped it
> out, but
> that didn't help. I ran a memory check and everything checks out ok.
> Any ideas where to look (Hardware? Bad CPU? Software?). Temperature
> is ok,
> lots of fans in the box and round cables so there is good air flow.
It's normal for the amount of "free" memory reported by top to
decrease to a small percentage of available physical RAM, as the
system uses that memory to cache as much stuff from disk as
possible. This does not necessarily mean that user processes are
leaking memory-- to determine that, you'd need to look for processes
which have their VSIZE grow without bounds over time (a period of
hours or days is normally required, not minutes, although especially
poorly written code might prove to be an exception). There are
memory leak checkers in the ports which can help diagnose this
situation such as valgrind, although I seriously wish for the system
malloc to come with something like the "leaks" utility found in MacOS X.
It's not normal for the system to panic; this often indicates a
hardware problem. But if you've done some hardware diagnostics & RAM
tests, it might be a legitimate problem elsewhere. There are some
brief suggestions in "man crash" and a chapter in the Handbook on how
to diagnose and debug system panics.
More information about the freebsd-questions