[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: How to write the __gc metamethod of referenced userdata?
- From: Duncan Cross <duncan.cross@...>
- Date: Wed, 22 Jun 2011 14:01:42 +0100
On Wed, Jun 22, 2011 at 9:41 AM, Xavier Wang <weasley.wx@gmail.com> wrote:
> I know I can make a table in registry to record the dependence of A and B,
> but it wastes memory, and you can't collect the memory in a table has
> dead-key, even it's a weak table!
If you are really so worried about this you could periodically call
something that copies the current contents of the dependence table to
a new table and replaces it in the registry.
> So is there any other way to tell lua this
> dependence?
No, since you rule out environment tables I don't believe there is any
other way than using a weak table.
-Duncan