Re: Informing luabind when my c++ created objects get deleted?

Harakiri <[email protected]> Tue, 29 Jan 2013 08:22:12 -0800 (PST)
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>


> That's what I would've suggested as well. Some kind of proxy
> with a weak 
> pointer. Why would that proxy be alive forever though?
> Surely it could 
> be deleted via Lua's garbage collection since it's only used
> in Lua?

Im creating the ProxyObject in C++, so i would assume that even using luabind - lua wouldnt try to delete it.

I give the ProxyObject as an arg to my lua functions, somebody could store it as an upvalue somewhere. 

When does lua garbage collect it ? As long as there is still a lua function that wants to access this "empty proxy object" - i doubt it would be garbage collected.

Somebody said you could somehow force it with extending lua _gc table and there do a check everytime the gc runs like if(proxyObject:object==null) // delete somehow the proxyObject

Im not sure tho how this works if you have multiple references to the same object from different env scopes.

------------------------------------------------------------------------------
Master Visual Studio, SharePoint, SQL, ASP.NET, C# 2012, HTML5, CSS,
MVC, Windows 8 Apps, JavaScript and much more. Keep your skills current
with LearnDevNow - 3,200 step-by-step video tutorials by Microsoft
MVPs and experts. ON SALE this month only -- learn more at:
http://p.sf.net/sfu/learnnow-d2d