🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #4980

Re: Memory Protection!

#4980
From: Peter da Silva
Date: Wed, 22 Aug 1990 23:59
35 lines
2027 bytes
In article <1410050@hpcvca.CV.HP.COM> charles@hpcvca.CV.HP.COM (Charles Brown) writes:
> > What's wrong with that? *I* always free all my memory before exiting a
> > program (well, I leave it up to "exit()" to free memory that stdio has
> > allocated) simply because I write re-usable routines...

> In Unix it is slower because the system can release all that memory
> much faster than you can.

Yes, this is true. And if you use "malloc" to allocate memory on the Amiga
it's true there as well. *but* eventually you're going to use that routine
in an interactive application... or just one that runs long enough for the
memory leak to be noticed... and it'll come back to bite you.

> The only reason I was concerned about this is because on the Amiga you
> *must* deallocate all that RAM because the system does not implement
> resource tracking.

So use "malloc". Particularly given the following:

> I mentioned to him that I intended to do this in
> all my code.  He told me it was a bad idea for code which would be
> used on Unix.

Use malloc and you can be as sloppy as you want... portable code should
use malloc anyway, since AllocMem isn't in P1003.1 or X3.159 (:->). But
beware that you're setting yourself up for problems somewhere down the
road.

Some people writing for BSD UNIX don't check the return value from malloc,
either. That doesn't mean it's a good idea.

You can always "#define free() /* nothing */".
-- 
Peter da Silva.   `-_-'
<peter@sugar.hackercorp.com>.
Technical Details
Message-ID: <6423@sugar.hackercorp.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!sugar!peter
References: <1145.26bd4989@waikato.ac.nz> <1410050@hpcvca.CV.HP.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!lavaca.uh.edu!uhnix1!sugar!peter
From: peter@sugar.hackercorp.com (Peter da Silva)
Newsgroups: comp.sys.amiga.tech
Subject: Re: Memory Protection!
Message-ID: <6423@sugar.hackercorp.com>
Date: 22 Aug 90 23:59:40 GMT
References: <1145.26bd4989@waikato.ac.nz> <1410050@hpcvca.CV.HP.COM>
Reply-To: peter@sugar.hackercorp.com (Peter da Silva)
Organization: Sugar Land Unix - Houston
Lines: 35