Re: INFO - memory leaks

From: Tom Dailey (tomd96@AIRMAIL.NET)
Date: 08/14/97


Hrm...

Does that create() and typedef struct mem_track {} track every single
function?
One thing about the insure software that's very nice is it's gui interface.
 If it sees
a mem leak, it will open a window and give you the exact line number.  Then
you just
double click on the gui line and it opens emacs to that exact line.  Maybe
added twink, but nice.

Oh, I did say it was a "donated" copy didn't I? free is always better than
$1500, eh??....

----------
> From: Daniel Koepke <dkoepke@CALIFORNIA.COM>
> To: CIRCLE@post.queensu.ca
> Subject: Re:  INFO - memory leaks
> Date: Thursday, August 14, 1997 2:40 AM
>
> On Wed, 13 Aug 1997, George wrote:
>
> -+For that amount of money I would adapt my buffer handling code to act
as a
> -+supplementary malloc() and track down the leaks in CircleMUD that way.
> -+Change the CREATE() macro, make a FREE() macro, and go to town.  You
could
> -+track who allocated what, where, and how much.
>
> Hm:
>
>   #define LOG_CREATE(sz)  fprintf(memlog, "%d bytes malloc'd on line %d",
\
>                                   sz, __LINE__);
>
> If I remember correctly __LINE__ will work beautifully.  I think there is
a
> __FILE__, too? <shrug>
>
> The problem comes when you want to FREE() something and you want to know
> exactly what it is that you're free'ing.  I suppose some sort of memory
> tracking system will work for this.  For instance:
>
>   typedef struct mem_track {
>      int alloc_line; /* line allocated */
>      char alloc_file[128]; /* file allocated in */
>      int bytes; /* bytes allocated */
>   } mem_track;
>
> Now our CREATE macro saves it all into a mem_track dynamically allocated
> array and our FREE() just looks up the data to report it.  Of course, the
> idea wouldn't be to turn on mem tracking and leave it on all the time.
> malloc() is already slow enough without overhead needed (we're talking
> about, for those that don't understand the dynamics of the mem tracking
> system, calling malloc() twice for every one CREATE() call: once to
actually
> allocate the memory to our variable, and again to allocate memory for the
> mem tracking for that variable).  So if you implement a mem tracking
system,
> you'll be instantly *doubling* the amount of calls to malloc(), and
slowing
> free() with searches.  Unless someone can come up with some better ways
to
> implement a mem tracking system, it would only exist to track memory when
> you were aware of memory leaks; or when you got really, really bored (the
> memory log would probably grow to a considerable size).
>
> Still, for so little code and the benefits from using it every once and a
> while...and the concept that in the end it serves to track down memory
> leaks (although in a slightly more manual way) without $1500 software is
> good enough.  A few hours reading a log file is more than acceptable
> compared to shelling out money that would pay for dinner (usually pizza;
I can
> cook, but rarely do) for approaxiametly a third of the year...
>
> Actually, there is a lot of software out there that costs a lot of money
for
> some strange reason.  For instance, 3D Modelers and Renderers.  Even the
> ones that suck in power and ease of use cost $400...:P  And the good
stuff
> can range from $4000 to $9000 and require insane computer equipment...
Why
> can't good things come with small price tags instead of small packages?
>
>
> -+Sounds like a good idea actually. I need to stop having those, it just
> -+gives me more things to do.
>
> Most of my ingenious ideas come to me a month after some guy just got a
> patent and made $15 million... :)  Really sucks to come upon a brilliant
> idea all by yourself to find out some big corporation's R&D team came
upon
> it and the patent is pending.  If my ideas would just come a month faster
> I'd be a rich man...
>
> -+So who wants to be the first to pay me $1,500 for it? ;)
>
> <gasp> You're suggesting that some people *won't* pay $1500 for it?
Anything
> to avoid reinventing the wheel!
>
> Speaking of money, maybe I'll start selling .sig lines, because you
gotta'
> admit I've come up with some pretty groovy ones ("Forgive me father, for
I am
> sin" is still a favorite, although the Ebonics version ["Fo'give me
fadda'
> 'cuz I be sin"] evoked some laughs, too :).
>
>
> --
> Daniel Koepke -:- dkoepke@california.com -:-  [Shadowlord/Nether]
> Perversion test: "There she blows!" conjures what image?
>
>
>      +------------------------------------------------------------+
>      | Ensure that you have read the CircleMUD Mailing List FAQ:  |
>      | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |
>      +------------------------------------------------------------+


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



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