Path: utzoo!utgpu!attcan!uunet!cbmvax!jesup
From: jesup@cbmvax.UUCP (Randell Jesup)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Minix, Unix on the Amiga, and flames on AmigaDOS braindamage...
Message-ID: <7638@cbmvax.UUCP>
Date: 11 Aug 89 23:45:39 GMT
References:  <1410023@hpcvca.CV.HP.COM>
Reply-To: jesup@cbmvax.UUCP (Randell Jesup)
Organization: Commodore Technology, West Chester, PA
Lines: 38

In article <1410023@hpcvca.CV.HP.COM> charles@hpcvca.CV.HP.COM (Charles Brown) writes:
>> 	Many requests for what people call "resource tracking" are actually
>> requests for memory protection.  I consider any program on ANY os
>> that doesn't free what it allocates (memory, file locks, whatever)
>> to be at best poorly written.
>> -- Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
>
>I try to write my programs in standard C so that they are portable
>between Unix and Amiga.  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.  As far as I know, that criticism applys to all operating
>systems except the Amiga's.

	Well, if you use the C library routines malloc() and free(), there is
no _need_ to free everything, since the library implementation and exit()
code takes care of freeing malloc()ed memory.  Doesn't mean I like the
practice: it places more reliance on the malloc to be unix-compatible, and
precludes replacing malloc (easily) with lower-level memory calls with less
overhead than malloc (such as AllocMem, or something like it).  Doing something
like that saved me over 1K, by dumping malloc, and made my program run faster.

	Another reason I prefer a style where everything is freed is that it
makes the code more reusable: you can take a subroutine and use it, and not
have to worry about using immense mounts of virtual space that you are no
longer using.  (Since you may use it repeatedly in a loop without exiting,
if it drops memory every time it can add up quickly.)

	As you might guess, I'm not a big fan of garbage collection.


-- 
Randell Jesup, Keeper of AmigaDos, Commodore Engineering.
{uunet|rutgers}!cbmvax!jesup, jesup@cbmvax.cbm.commodore.com  BIX: rjesup  
Common phrase heard at Amiga Devcon '89: "It's in there!"