lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


Yes, I'm in the same boat. I'm just binding against other libraries
and don't necessarily control the API. And incidentally, SDL is one of
the libraries, but I discovered a bunch of unrelated libraries I'm
using have this same problem. And all the edge cases seem to keep
coming back to 2 extremes...fix GC or 100% manual management; a blend
of the two keeps causing me new edge problems.


> I have another idea: What about splitting the A objects into two objects
> A and A_finalizer. The A_finalizer only lives in A's uservalue table, so
> it usually will become garbage at the same time as A. Whenever you
> associate a B object with the A object, you "disarm" the old
> A_finalizer, create a new one, and put both the B object and the new
> A_finalizer in A's uservalue table. Since the A_finalizer was created
> after the B object, it will be finalized before it.

Nice thought.

I tried doing a simpler mockup to see what happens if I create
newuserdata during an object's finalizer. It looks like the problem is
still lua_close. But this time it looks like that lua_close may not
get around to cleaning up these new objects at all.


Thanks,
Eric
-- 
Beginning iPhone Games Development
http://playcontrol.net/iphonegamebook/