[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 <30tv4p$dhv@debbie.cc.nctu.edu.tw>, Yao-Sheng Cheng
<ee780569@twin1.src.ncu.edu.tw> wrote:

|     I am working to build a multimedia authoring system using MCL&CLOS.  
|I have a problem that how to release the memory of objects created 
|through make-instance. Does the MCL garbage collector is so clever to 
|collect these memory back or I must explicitly call some functions to 
|free these memory?

Sorry folks.  Tried e-mail twice, but it bounced.

As has been noted, MCL is that clever [actually any Common LISP
implementation is required to be that clever], *BUT* there is one gotcha
with MCL and garbage collection that has not yet been noted.

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'm not sure exactly where to point you for good examples of mac pointer
management; perhaps somebody else would care to suggest one of the
user-contributed documents for this.

-- "TANSTAAFL"  Rich lynch@ils.nwu.edu