Newsgroups: comp.lang.smalltalk
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!torn!nott!cunews!dbuck
From: dbuck@superior.carleton.ca (Dave Buck)
Subject: Re: Garbage Collection ?
X-Nntp-Posting-Host: superior.carleton.ca
Message-ID: <DJu3t6.79u@cunews.carleton.ca>
Sender: news@cunews.carleton.ca (News Administrator)
Organization: Carleton University, Ottawa, Canada
References: <INFO-CLS%95121116540159@vm.gmd.de> <4ar0m8$pop@news2.ios.com> <DJMBs2.HvF@cunews.carleton.ca> <4b5ap4$pgt@news2.ios.com>
Date: Tue, 19 Dec 1995 12:53:30 GMT
Lines: 41

In article <4b5ap4$pgt@news2.ios.com>, vlad <vlad@gramercy.ios.com> wrote:
>dbuck@superior.carleton.ca (Dave Buck) wrote:
>
>>It's clear that most languages allow you to control memory allocation.
>>That's very useful.  Can you explain how it's useful being able to
>>control deallocation rather than letting a garbage collector do it?
>
>How about deallocation of external resources that are "owned" by some
>Smalltalk object that is not needed anymore?

Use 'release'.  That's what it's for.  Besides, what you're talking
about is an issue of program functionality (such as closing files at
the proper time) and not garbage collection - granted, they're related
in this example.

>Normally, you never know when the garbage will be collected. The
>VisualWorks can notify you when the object is about to be collected at
>a some point of time and than you can of course trigger some message
>to be send to your object etc....

Using WeakArrays, finalization, etc.

>But typically I don't want to wait until garbage collector will come.
>If the use of external resources is expensive, I use elegant approach
>of implicitly using object destructors (and delete operators)  in C++.

But the garbage collector is responsible for managing memory, not
resources.  You can get the Smalltalk garbage collector to tell you
when it's deleting objects and use it for free'ing resources, but if
they're expensive as you say, you must manage them yourself anyways.

David Buck
dbuck@ccs.carleton.ca

_________________________________
| David K. Buck                 |
| dbuck@ccs.carleton.ca         |
| The Object People             |
|_______________________________|


