If you allocate memory and never free()s it, it's considered a leak. (However, one time allocs used through the programs life is not a big deal) What causes issues are programs that alloc many times, and never free anything.
My C++ is weak. I believe 'new' actually requires a 'delete' to free the memory, so using 'new' without 'delete' when you are done does leak memory. Jason -----Original Message----- From: Jed Yang [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 09, 2003 1:51 PM To: Mike Barton; ROM Mailing List Subject: Re: Freeing recycled memory When I said "What is the point of freeing them yourself," I was actually saying "[. . .] yourself upon exit," since he said he wants to free them upon exit himself. (Now I know that he wants to test for memory leaks.) So for your explanation of memory leak, I would grasp onto this opportunity to ask a simple question: Is this considered a memory leak? char *buf = new char[100]; buf = new char[100]; Now I cannot use the first 100 char's I allocated. This would be a memory leak in its simplist form, correct? Htam ----- Original Message ----- From: "Mike Barton" <[EMAIL PROTECTED]> To: "Jed Yang" <[EMAIL PROTECTED]>; "Jason Gauthier" <[EMAIL PROTECTED]>; "ROM Mailing List" <[email protected]> Sent: Tuesday, September 09, 2003 10:34 AM Subject: Re: Freeing recycled memory > Isn't allocated memory always automatically freed upon program termination? > Then what is the point of freeing them yourself? Furthermore, I thought ROM Great, if you want to reboot your mud constantly. > just keeps a list of, say desc's, structures that are not in use; and > remove it from the linked list of unused to the list of current, again say > desc's, structures and initialize for the use. So the memory allocated to a > structure is never released for another structure to use. So if you really > want to, couldn't you just free all the unused desc's followed by all the > unused ch's and the note's and so on and so forth... Don't kick me if I > totally messed up your point, though. I doubt that he's having a problem with the MUD using too much memory when everything works correctly. More likely he's worried about a memory leak somewhere in the code. A memory leak is basically where you lose the pointer to some block of allocated memory, so you aren't able to free or reuse this memory, and it just sits there. Memory leaks usually come up with strings in ROM. Since code dealing with strings is everywhere, it's pretty easy for something to be coded incorrectly and lose a pointer to one. > > Htam > ----- Original Message ----- > From: "Jason Gauthier" <[EMAIL PROTECTED]> > To: "ROM Mailing List" <[email protected]> > Sent: Tuesday, September 09, 2003 5:27 AM > Subject: Freeing recycled memory > > > I know, this is pretty stupid, because it's permanently allocated :P > > > > Whatever. I'm trying to actually memory leak check my mud, and it's > > difficult when all the recycled memory is not freed. > > > > What can I do to keep track of the allocations to actually free them > > (upon mud exit). > > > > I considered making a linked list of the allocations but then decided I > > didn't want to have to allocate a list to keep track of allocations :) > > > > I'm not seeing an easy way with what's already there to do this. Perhaps > > I'm over looking something. > > > > Suggestions? > > > > Thanks, > > Jason > > > > -- > > ROM mailing list > > [email protected] > > http://www.rom.org/cgi-bin/mailman/listinfo/rom -- ROM mailing list [email protected] http://www.rom.org/cgi-bin/mailman/listinfo/rom

