[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Resurrecting Objects
- From: Marc Lepage <mlepage@...>
- Date: Tue, 12 Nov 2013 14:09:16 -0500
What I'm doing, and what I'm worried about, is precisely this:
"For example, our proxy system for Objective-C objects uses a weak table
mapping light userdata Objective-C object addresses to Lua proxies so
that we generate the same proxy for a userdata object if we need to
publish it to Lua multiple times. It would be really bad if we could end
up using a proxy that had been scheduled for finalization."
And it sounds like without "indirect" references, my "direct" references will be OK:
"Direct caches of userdata get cleared when marked for finalization. It's
just indirect caches that have problems and those need something else
to keep the values alive."
I was also worried about "It can happen so that the new view is allocated exactly at the same address as the old one" but as in the thread, if my userdata isn't finalized, the C++ object remains so nothing else can be allocated there. I do have another case where I can have auxillary data cached to the light userdata, without a full userdata keeping it alive, and I already intended to hook in a callback to the object's destructor to clear any such auxillary data. That callback would only be active if such auxillary data existed.
Still, reading through that thread, it *seems* to me like I should be OK, but it's not *obvious* to me that it's OK.