Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!ucbvax!agate!shelby!polya!rokicki
From: rokicki@polya.Stanford.EDU (Tomas G. Rokicki)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Minix, Unix on the Amiga, and flames on AmigaDOS braindamage...
Message-ID: <11280@polya.Stanford.EDU>
Date: 11 Aug 89 18:56:57 GMT
References:  <1410023@hpcvca.CV.HP.COM>
Sender: Tomas G. Rokicki 
Organization: Stanford University
Lines: 26

charles@hpcvca.CV.HP.COM (Charles Brown) writes:
> I told a friend of mine (who doesn't own an
> Amiga but who knows a great deal about Unix) that I planned to change
> my programming style to explicitely free all memory that I had
> malloced.  He said that under Unix that was a bad idea because the OS
> can free the memory much faster than my explicit calls.  Hence I would
> be slowing down my program (as well as making it larger) and would get
> no benefit.

Depends on the style program you write.  First, the program won't be much
larger, typically, as the `free' stuff is a simple traversal of a linked
list.  Secondly, even under Unix in *many* cases freeing memory is crucial.
The virtual address space of a process is limited, and you can easily run
out if all you do is malloc() with no free's.  Even without this, though,
if you don't free(), your usage of malloc()'d memory may become fragmented,
distributing your `working set' over a much larger number of memory pages,
causing swapping and other bad behavior.

If your program runs for a while, possibly over several jobs in the same
invocation, and you must malloc() memory, please free() it when appropriate.

If all you want is Unix/Amiga compatibility, might as well use the
malloc() functions supplied by the various compiler vendors, as they
are compatible . . .

-tom