Re: luabind - problem with luabind::object reference

Jason McKesson <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <[email protected]>
Yes, the object has a reference. However, the object should releases the 
reference when it is destroyed. Which happens immediately after creation.

No, his problem is the fact that the object is /still/ on the stack. 
Luabind's from_stack call does /not/ pop it off of the stack for you; 
you have to do that yourself.

On 12/20/2009 9:30 AM, Linker wrote:
>  luabind::object obj(luabind::from_stack(ls, -1));
> The "obj" hold a ref.
>
> On Sun, Dec 20, 2009 at 18:25, Oleksandr . <[email protected] 
> <mailto:[email protected]>> wrote:
>
>     Using C++, lua5.1, luabind 0.7
>
>     *** Lua code: ***
>     -- allocates near 8Mb of memory
>     function fff()
>         local t = {}
>         for i = 1, 300000 do
>             table.insert(t, i)
>         end
>         return t
>     end
>
>     *** C++ code ***
>     {
>         luaL_dostring(lua_state, "return fff()");
>         luabind::object obj(luabind::from_stack(ls, -1));
>     }
>     lua_gc(l_, LUA_GCCOLLECT, 0); // collect garbage
>
>     Result: Lua still have a 8Mb allocated memory. Garbage collection
>     ignores that table object. It has references anywhere? But where?
>     That table deallocates only on program exit (when "lua_close"
>     function called). How to solve this problem and what is the reason?
>
>     Thank you.
>
>     ------------------------------------------------------------------------------
>     This SF.Net email is sponsored by the Verizon Developer Community
>     Take advantage of Verizon's best-in-class app development support
>     A streamlined, 14 day to market process makes app distribution
>     fast and easy
>     Join now and get one step closer to millions of Verizon customers
>     http://p.sf.net/sfu/verizon-dev2dev
>     _______________________________________________
>     luabind-user mailing list
>     [email protected]
>     <mailto:[email protected]>
>     https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
>
>
> -- 
> Regards,
> Linker Lin
> [email protected] <mailto:[email protected]>
>
>
> ------------------------------------------------------------------------------
> This SF.Net email is sponsored by the Verizon Developer Community
> Take advantage of Verizon's best-in-class app development support
> A streamlined, 14 day to market process makes app distribution fast and easy
> Join now and get one step closer to millions of Verizon customers
> http://p.sf.net/sfu/verizon-dev2dev
>
>
> _______________________________________________
> luabind-user mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>

------------------------------------------------------------------------------
This SF.Net email is sponsored by the Verizon Developer Community
Take advantage of Verizon's best-in-class app development support
A streamlined, 14 day to market process makes app distribution fast and easy
Join now and get one step closer to millions of Verizon customers
http://p.sf.net/sfu/verizon-dev2dev

_______________________________________________
luabind-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/luabind-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.