NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: debugging a memory leak
On Fri, May 20, 2016 at 02:20:39PM -0600, Swift Griggs wrote:
> On Fri, 20 May 2016, Manuel Bouyer wrote:
> > what tools do we have on NetBSD to find a memory leak in a userland
> > program (actually OpenCPN - which is a large C++ program with dynamic
> > libraries and uses dlopen()) ?
>
> Manuel, I'm guessing you are a much better C programmer than I, but I can
> relate what I use. I do three different things:
>
> 1. If it'll compile on Linux, I'll test it with valgrind and just apply
> the results on the NetBSD side.
I tried this, as opencpn is developed for linux. It builds and runs,
but the plugins won't load, the main application lacks some symbols
(but not all !).
I'm not seeing the lack on Linux; I've not tried running without the
plugins on NetBSD yet.
>
> 2. ElectricFence, but I doubt it'd work with libs dlopen()'d. Then again,
> if you used it with LD_PRELOAD you might be able to pre-empt the symbols
> even in the dynamic libs (in theory).
I though ElectricFence would only detect things like use after free or
out of bound access, but not memory leaks ?
>
> 3. I created a cheeseball reference counter similar to the one in glib by
> just wrappering malloc(). It just add/drops/prints a linked list of
> structs which are entries I'm tracking. When everything is working
> perfectly, I remove it. Voila clean memory management without krufty
> GC overhead!
>
> > The memory usage of the process is slowy growing, until the systems gets
> > out of ram/swap and kills it (on my evbarm which has no swap it takes
> > about 2 days).
>
> My guess (which ain't worth much, take it with a grain of salt) you'd find
> it pretty darn fast with valgrind. It's never failed me, but it's limited
> to Linux, Darwin, and Solaris.
Yes, valgrind was my first idea. I guess I'll have to debug this
hidden symbols problem...
--
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
NetBSD: 26 ans d'experience feront toujours la difference
--
Home |
Main Index |
Thread Index |
Old Index