Re: [Circle] Memory/Formalities

From: JTRhone (ujtr@lady.cs.sunyit.edu)
Date: 11/10/96


On Sun, 10 Nov 1996 pstecker@netbox.com wrote:

> memory allocated by the program upon exiting the program.  I have been
> yelled at constantly by different people to *ALWAYS* 'free' up anything I
> malloc when exiting/quitting a program.  Is this really that important?
> Or can we trust the OS to truly release all memory we allocate?  I
> honestly think it would be a hassle to go into the code and have it free
> up everything (since theres just so much that needs to be free'd).  Is it
> worth the effort/time?  Pros?  Cons?
> 
> Penstar/Patrick

Pro: 
Using a mem allocation tracker and logger such as dmalloc will only prove
useful if you free up everything before exiting the program.  Memory leaks
are hard enough to find in a large codebase and not freeing up everything
before you jet only makes debugging and leak tracking that much more
impossible.  

Pro:
You know absolutely that your program is releasing its resources back to
the OS.  Not doing this leaves just a hint of mystery in the mix, though
most modern OS handle it quite well, you just can't be sure.  Even if
there is only a 1 percent chance that all the resources are not being
released, why take that chance when you can prevent it? :)

Con:
Code.  More code.  Yes, it takes code to free up your character lists,
room lists, and object lists.  Along with all the plrmail, and board
messages, etc.

Con:
Time.  Of course more code means more time in writing it and debugging it
and many of us dont have the time to code anything other than 'additions'.
Personally I think that I myself should do a 50 / 50 mix of addition code
and optimization/cleaning code.  In other words, I should be spending just
as much time adding new code as I do maintaining and streamlining existing
code.  Too many times I get drawn off down a different avenue forgetting
my original code intentions :)  I think, in the long run, it would save me
some time and produce much better code.  Being the stubborn and impatient
fool I am, however, I'll stick to my 80/20 slice.

Well there ya have it from my view.  Is it worth it?  I think so.  I did
it and I use dmalloc to track memory leaks now if I get suspicious and it
works like a charm.  It was a necessity to free everything up before I
even thought of trying to use dmalloc.

Ok.  Back to my pizza and coke for breakfast.

jtrhone aka vall RoA (plug: roa.sunyit.edu 4000)



+-----------------------------------------------------------+
| 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/18/00 PST