Newsgroups: comp.lang.dylan
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!howland.reston.ans.net!news.cac.psu.edu!news.pop.psu.edu!hudson.lm.com!netline-fddi.jpl.nasa.gov!wiretap.spies.com!times.aux.apple.com!mumbo.apple.com!gallant.apple.com!news
From: Walter Smith <wrs@apple.com>
Subject: Re: Dylan Runtime Environment
Sender: news@gallant.apple.com
Message-ID: <1995Jan18.190603.11397@gallant.apple.com>
Date: Wed, 18 Jan 1995 19:06:03 GMT
X-Xxdate: Wed, 18 Jan 1995 18:56:01 GMT
Content-Transfer-Encoding: 8bit
Content-Type: text/plain; charset=ISO-8859-1
References: <9501131747.AA12748@locutus.quadralay.com> <REC.95Jan14163824@elf115.elf.org> <3fa0gv$2e4@cantaloupe.srv.cs.cmu.edu> <3fbif1$6ia@flop.mcom.com>
Mime-Version: 1.0
Organization: Apple Computer, Inc.
X-Newsreader: Nuntius Version 1.3b19_68K
Lines: 45

Ben Allums, allums@quadralay.com writes:
> Since the Dylan runtime environment handles memory management for you,
> Dylan programs should never have memory errors.

Garbage-collecting environments do have a form of "memory leak" that occurs
when programs don't eliminate all references to objects that are actually
no longer needed.

This is a common issue on the Newton platform.  Newton uses a dynamic
language with garbage collection, but unlike most such systems to date,
Newtons have a pretty tiny amount of memory.  Programmers are thus quite
concerned that they are getting all their garbage collected, and want to
make sure they've killed all references to objects that should be
considered garbage.

For example, if you allocate a big array in a loop:

	loop begin
		x := Array(2000, nil);
		...
	end;

You really want to make sure the old array is dead before you allocate the
new array.  (In this simple case one could argue that you should just fill
the same array with nils on each iteration, but ignore that.)  Otherwise,
you're wasting 8K of heap for the old array, which may be the difference
between working correctly and getting an out of memory exception.

	loop begin
		x := nil;	// Allow old value to become garbage
		x := Array(2000, nil);
		...
	end;

So in Newton programming, the tool you want is one that answers the question
"Why isn't that object garbage now?".  On a small Dylan platform, I imagine
you'd want the same tool.

- W

---------------------------------------------------------------------------
Walter Smith                                        Internet: wrs@apple.com
Newton Software                                     AppleLink: WALTER.SMITH
Apple Computer, Inc.     PGP key at ftp://ftp.apple.com/pub/wrs/PGP-key.asc
+1 408 974 5892            E1 20 C3 0A DE 27 89 06  0B 35 08 65 0C FB A7 41
