destructors, how?

Allen Wirfs-Brock Allen_Wirfs-Brock at Instantiations.com
Tue Oct 22 20:50:37 UTC 2002


At 12:21 PM 10/22/2002 -0400, Lex Spoon wrote:
>...
>However, finalization turns out to be fairly limited with a typical
>garbage collector like Squeak's.  It seems to work best as a protection
>against stupid mistakes during development, and not as a general programming
>technique.  It's interesting to think about memory systems that can do
>better at this, but that's not practical right now.  (Though, Squeak would
>be a fine platform for doing memory management experiments!!)
>
>This really irritates me intellectually.  Garbage collection works so
>beautifully for *one* type of resource at a time.  Note that you can
>run garbage collections efficiently if you just wait until memory is
>low.  However, how do you do this for multiple kinds of resources in
>addition to memory, while staying reasonably efficient?  For example,
>suppose you have an application that *really* starts chewing through
>sockets without using much memory?  Then collecting the sockets means
>collecting memory more frequently, which sounds inefficient.
>
>It seems like garbage collection should generalize somehow, but I have
>absolutely no idea what that way would be.

The best explanation I've ever heard for why you are unlikely to see 
garbage collection generalized in this manner was by George Bosworth of 
Smalltalk/V fame.  George's explanation basically goes like this:  Garbage 
collection is a resource management solution for a resource that fits a 
particular  "economic" model (very large resource pool, each resource has a 
very low value (who cares if you loose a few bytes out of megabytes), very 
high churn rate, moderate wastage is acceptable, etc.).  Garbage collection 
algorithms and policies are all designed and specifically optimized for 
this specific resource management problem and simply are not appropriate 
for the management of resources subject to a very difference set of 
economics. In addition, there is no reason to believe that there is a 
single universal resource management mechanism that can be used to 
optimally manage all types of resources.

The problem with finalization is that it applies memory resource management 
policies to other resources (like postgres connections) that have a very 
different set of economics associated with them.

Allen_Wirfs-Brock at Instantiations.com




More information about the Squeak-dev mailing list