[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to free the memory occupied by the instance object?



In article <lynch-2507942005550001@129.105.100.156> lynch@ils.nwu.edu (Richard Lynch) writes:

   If you have created mac pointers [machine specific data structures], and
   have stored them in slots, you need to be sure to dispose of them when
   they are no longer needed.

   For example, a window has a wptr slot that contains a WindowPtr [?] record
   that can be passed to MacOS ToolBox trap calls (#_xxx (wptr <window>)). 
   When a window is closed, its wptr is disposed.

   The upshot is, pointers and handles are NEVER disposed automatically; you
   must take care of them yourself if you create them.

   All the MCL builtin code, and [almost for sure] all the user-contributed
   code do this properly, but it's up to you to do it properly for your own
   mac pointers such as PICT, SND , etc handles.

I thought that MCL offered a (possibly undocumented) finalization
capability, whereby one can specify a function to be run when a given
object (or perhaps any object of a given class) is about to be
garbage-collected.  If so, one could specify a finalizer for any class
of object that is known to retain mac-pointers in specific slots.  Of
course, this assumes that the entire heap is GCed at least
occasionally.
--
        Lawrence G. Mayka
        AT&T Bell Laboratories
        lgm@ieain.att.com

Standard disclaimer.