[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: newproxy()
- From: Roberto Ierusalimschy <roberto@...>
- Date: Tue, 24 Nov 2009 09:37:00 -0200
> Can't you skip queuing the weakly-referenced object in that case,
> marking it reachable instead? This does not guarantee forward
> progress, but I suppose you can't do that anyway when memory is tight.
The problem is to keep everything synchronized. An object may be in
several different weak tables and also may have a finalizer (__gc).
Lua would have to make sure that all queues have space before doing
anything.
> Java solves this by allocating enough pointer fields when the weak
> reference is created, so that the queue data structure can use that
> later without further memory allocations. This is probably not
> suitable for Lua because you don't want the weak table machinery on
> the ordinary table lookup path.
I thought about that. The queue could be resized toghether with the
table, out of the lookup path. But the queue is a regular table, so
the program could add other elements to it and fill the previously
allocated space.
-- Roberto