[Circle] Re: Memory Leakage

From: Ron Hensley (ron@cross.dmv.com)
Date: 08/07/96


Okay my own memory leakage has been caught and hung in the public square.
Mine was not a patch, but rather code one of my fellow coders hand coded.

That being code to allow color codes in say, goss, titles etc
Seems he was mallocing a buffer EVERY time it was called and nevered 
bothered to free it anyplace, or just assumed it would be freed on its own.

I just gave his routine a global buffer of MAX_STRING_LENGTH just like 
buf, buf2, etal to use.

Now as to how this relates to anyones elses memory leakage troubles.
To find this leak, i searched for all occurences of malloc.
I added a mudlog call directly after each one, spitting out file name, 
line number, bytes allocated

I then went to my shell and repetetively did an:
  ps -aux | grep circle
This shows the memory usage under BSDi

Well i noted that the memory went up by 8 bytes all the time, save when 
people login etc, but the CONSTANT increase appeared to be in 8 byte 
increments.

So i went to my syslog, and looked for my debug messages, with allocation 
size of 8 bytes. only one place did that, and wouldnt you know it, that 
was my troubles.

Had it not been QUITE so easy, i would have then also added debug 
messages to all free() calls and looked for anything glaring, like 
unmatched malloc/free pairs

If you have a leak, youd have to at least HOPE there's only one, and its 
size is going to be someone conformed

I did try lint as the one kind gentelmen suggested, but my lack of 
knowledge on its usage, even after studying man pages, kept it from being 
of much use to me.

Anyways, I suggest a similar tactic to those having similar troubles.

To those who had contrcutive advice on ways to track it down, 1 million 
thanks.

To those who decided my questions, was a good reason to flaunt themselves 
as the only REAL coder alive, and me just a stupid peon that deserves any 
troubles i might ever have .... well ill just concentrate on the REAL 
people who only post when they have something helpful to say.

    *******************************************************************
    *   Ron Hensley                     ron@dmv.com                   *
    *   Junior Systems Administrator    http://www.dmv.com/~ron       *
    *   DelMarVa OnLine                 749-1111 Ext. 403             *
    *******************************************************************


+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/07/00 PST