On Thu, Aug 20, 2009 at 1:56 PM, Lawrie Nichols<lawrien@gmail.com> wrote:
Hi all
I've got a problem trying to use weak-referenced tables. While they perform
as described, it's not quite what I had hoped for. The problem is really
that entries in such a table (be it weak-keyed or weak-valued) remain
accessible until the underlying object is marked (or unmarked ??) by a GC
cycle.
So, my questions are:
1) is it possible to force the GC to just mark an object (or unmark it ??)
without running a full GC cycle ?
2) if the answer to 1) above is yes, then is it possible for table
keys/values to 'hide' the table entry if their underlying object has been
marked to die ? Currently, is seems that such tables will only remove
entries as part of a GC cycle.
This is usually done by setting that field of the table to nil,
whether it is weak or not. The GC makes no guarantees (as far as your
code is concerned) about when it will run, mark, or collect objects.
The GC just does the "right thing", if you're having problems, it
seems like you are using weak tables for the "wrong thing". If I
misunderstand, could you explain your use a bit more?
Matthew