Re: [SYSTEM-LINUX] Finding Memory Leaks : Help please.

From: George Greer (greerga@circlemud.org)
Date: 01/31/02


On Thu, 31 Jan 2002, Justin Adler wrote:

>   Downside is, i've been programming the game for around 5 years now
>(yes .. starting from bp11 i think?) and the game could be stable for a
>day or two then randomly crash. sometimes a week then crash. And's it's
>always a random part of the code (gdb core).  So i cannot unroll 5 years
>worth of modifications.

Run ElectricFence. (Makefile: "LIBS = -lefence")  It catches memory
overruns and can be made to catch underruns.  Make sure you have a *lot* of
swap space if you run it, especially if you leak memory.  It won't prevent
the crashes but it'll likely show you exactly what is the problem instead
of showing you what hits the symptom hours later.

>   So last night i grabbed MemProf and tried that. Wow. lots of 1k memory
>leaks and a score of 20k memory leaks.  I left the game run all night
>with a simple BOT running around. The game crashed 8 hours later ...

Make sure you're using bpl20 and not a CVS release. The first cut I
committed to CVS just made sure 'bin/circle -c' didn't leak.  Then later I
made sure the whole bootup/shutdown cycle didn't leak.  So bpl20 should
have everything, except what you've done personally to extend the MUD.

>    Are there any special paramaters for the Makefile to make the program
>show memory leaks, etc.

I use:

      MALLOC_TRACE=/tmp/circle-trace bin/circle
      mtrace bin/circle /tmp/circle-trace

See sysdep.h in bpl20.

>P.S. Running MemProf + bp20 (i downloaded it last night) produced no memory
>leaks at the end of bootup. [going to sleep mode]   :)

If you hit Ctrl+C at 'going to sleep' then the leak-detection code never
ran.

--
George Greer
greerga@circlemud.org

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/25/03 PDT