home *** CD-ROM | disk | FTP | other *** search
- Path: senator-bedfellow.mit.edu!red-branch!rid
- From: rid@red-branch.MIT.EDU (Shawna Grimm)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Must I free my linked lists? (GCC)
- Date: 22 Jan 1996 15:52:54 GMT
- Organization: Massachvsetts Institvte of Technology
- Message-ID: <4e0bsm$rkb@senator-bedfellow.MIT.EDU>
- References: <4dudic$aif@vixen.cso.uiuc.edu> <4dusp9$7k3@senator-bedfellow.MIT.EDU> <4dvn6t$lc3@hamilton.maths.tcd.ie>
- NNTP-Posting-Host: red-branch.mit.edu
- X-Newsreader: TIN [version 1.2 PL2]
-
- David Malone (dwmalone@maths.tcd.ie) typed in the following on 22 Jan 1996 09:59:57 -0000:
- : rid@red-branch.MIT.EDU (Shawna Grimm) writes:
-
- : >Unknown (Dannyman@uiuc.edu) typed in the following on 21 Jan 1996 22:09:16 GMT:
- : >: I'm writing a program that makes use of dynamic memory allocation through
- : >: linked lists using malloc() ... from an implementation PoV there's no need
- : >: to flush this stuff as after the queue is created it's output and the
- : >: program exits. My question is;
-
- : >Yes, you _should_ free any memory that you allocate in your program.
- : >Memory that is allocated and not freed will not be returned to the system
- : >unless you turn the machine off, so if you want your memory back, you
- : >must free it. Personally, I would prefer to use AllocMem() or AllocVec()
- : >(with FreeMem() and FreeVec() ofcourse).
-
- : I think the memory is freed in when you use malloc - in gcc or SAS/C.
- : Weither this is in malloc's spec is another matter. I think
- : memory you malloc ( as opposed to AllocMem'ed ) seems to be tracked
- : and freed at exit. I noticed this when I was testing something I was
- : writing on unix, and hadn't finished the memory stuff. It allocates
- : about 8MB, which went fine, but I was quite shoked to see that I could
- : run it twice in a row ( I only have 10MB of ram ).
-
- : David.
-
- I cannot confirm or deny this, as I don't have my amiga up and running at
- the moment, BUT, it is considered 'good programming' to free up all
- memory you have dynamically allocated. So, to keep your nose clean,
- free() alled malloc()'ed/calloc()'ed memory.
-
- * Lars M. Hansen
-
-