This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: destroy and garbage collection


On 05/27/2010 02:07 AM, teong leong chuah wrote:
Hi Per,

Can you explain how objects in kawa are destroyed or set as
unreferenced and waiting for garbage collection?

I'm not sure what you're asking for, beyond explaining garbage collection, which you seem to know about.

http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-8.html#node_sec_5.10

This works in general but what I haven't figure out is how to destroy
objects in kawa. We would typically have many such objects store in a
scheme list or a hashtable and we've been doing (set! mylist '()) or
empty the hashtable.

Does that ensure the deletion of such objects that were previously
inside the list?

Essentially. You don't "destroy" or "delete" objects in Kawa (or Java), but they get garbage-collected when unreachable. So you may sometimes explicitly need to some object unreachable, typically by nulling (or niling) the variable(s) that refer to the object.

We have our own thread object that is created using a loop, a sleep
and future to create a periodically firing thread that execute a
procedure. We've put threads inside our objects and it seems with, the
thread still firing and running, the objects that have been emptied
from the list are still alive.

This is rather too vague to say much.


But note there is nothing guaranteed about garbage collection
deleting objects - if there is enough memory it is quite possible
garbage collection will never get around to deleting the objects -
because there is no need to.  Especially "older" objects are less
likely to be deleted, because a generational garbage collection
will focus on deleting "young" garbage (i.e. relatively
recently-created objects), and never get around to deleting
older garbage - because just deleting the younger objects is
good enough.

If I stop the thread there wouldn't be
any way of knowing whether my objects are alive or not.

Can you walk me through the scheme way of destroying objects?

There is nothing Scheme-specific about Kawa GC - it's just the Java garbage collector. -- --Per Bothner per@bothner.com http://per.bothner.com/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]