[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: RE: tables and the gc
- From: RLake@...
- Date: Mon, 28 Apr 2003 17:24:26 -0500
AB> This example doesn't cut it for me. It is often the case when one
can not let Lua destroy objects in its own time due to system
interdependencies. If system A needs system B to manipulate data members
of A, clearly, by the time Lua decides to collect A, B may have long
gone. So, there must be a way to GC things on the spot in a fairly
straightforward and convenient fashion. What about weak keys and values?
Could they be of any help to the original poster? I have never used them
myself.
Truly scarce resources cannot be left to garbage collectors to deal with.
Nick is absolutely right about that.
Weak tables don't help much either, I'm afraid, as they also depend on the
garbage collector running.
The problem is that there is no guarantee that the garbage collector will
ever run (at least until process termination) because it is only aware of
one resource: memory. It does not run until it has some indication that the
resource it manages is in need of management. If your program runs for some
time without ever allocating a new object (or even without allocating many
new objects), the garbage collector will not run in this time.