On 18 Jan 2015, at 17:43, Johan Fabry <jfabry@dcc.uchile.cl> wrote:
On Jan 16, 2015, at 12:04, Henrik Johansen <henrik.s.johansen@veloxit.no> wrote:
On 16 Jan 2015, at 1:25 , Johan Fabry <jfabry@dcc.uchile.cl> wrote:
As Iâve been asked, Iâll clarify a bit more. When I said it worked before I was actually wrong because I had forgotten to remove some alternative cleanup code (the alternative works but itâs like using a cannon to kill a fly).
This is part of the interpreter for Live Robot Programming that Miguel and I are working on. As part of that we need a data structure that holds scopes, for variables but also for other things. It turns out that for the variables part we can map rather nicely to classes, which gives us a bunch of advantages. So for each scope I generate a class. The scope keeps that class in a âvarsâ instance variable (there are never any instances of these classes BTW). When the scope is garbage collected I want to remove the class from the system. So I put #finalize in the scope with the idea to remove the class, but it turns out that âvarsâ is always nil. So in the end it did not work out ...
You're probably registering the scope for finalization before setting the vars insvar? The shadow copy is made at the point of registration, so any subsequent assignments to the scope's instvars is not accounted for.
Yes! Silly me :-/ that was the problem! Thanks for pointing it out!
Itâs still not perfect: when running the tests +-half of the generated classes are not removed, but maybe the test runner still holds some references. As I said before, I donât have much time to spend on this ⦠I will need to make some time to investigate more later.
Johan, I think that is quite normal. It is hard to force GC and thus weak registry and finalisation behaviour. After a while they will probably be gone. I see the same thing with lingering sockets, network connections or worker threads. In the end everything gets cleaned up. If not, you might have a problem ;-) Sven
---> Save our in-boxes! http://emailcharter.org <---
Johan Fabry - http://pleiad.cl/~jfabry PLEIAD lab - Computer Science Department (DCC) - University of Chile