0.91 luabind::call_function - leak
Harakiri <[email protected]> Wed, 11 Jul 2012 08:16:40 -0700 (PDT)
| Newsgroups | gmane.comp.lang.lua.bind.user |
|---|---|
| Message-ID | <[email protected]> |
When i call a lua function with a non primitive object (e.g. not string, int) which class i registered to luabind - everytime i call the lua func, the memory usage increases. I have a loop, that calls the lua func 100k times - after that my usage increases by a few MB. The lua func is empty and does nothing. However, if call lua_gc(luaState, LUA_GCSTEP, 1); after every invoke, the usage does not increasse ( but at the end, 4KB remain no matter how many loop iterations i have - i gather this is the metatable for the object class that remains?!). Now when i use instead of luabind::call_function<void>(fn,MyObj); directly lua : // push function on stack fn.push(fn.interpreter()); luabind::globals(luaState)["MyObj"] = myObj; // put the obj onto the stack as func arg lua_getglobal(fn.interpreter(), "MyObj"); // call with 1 param lua_pcall(fn.interpreter(), 1, 0, 0); I dont need to use lua_gc(luaState, LUA_GCSTEP, 1) to have no leak at all after each invocation. (Moreover the performance increases massively, and cuts down execution time to half) Unrelated to call_function but to luabind in general, if i put multiple objects of the same class into the globals luabind::globals(luaState)["MyObj1"] = myObj1; luabind::globals(luaState)["MyObj2"] = myObj2; and delete the objects (and even NULL the luabind globals) - about 4k remain everytime (tho overwritting the same identifier does not increase it) - so for some reason it seems that luabind does not reuse the class metatable and creates a new one of each object? It seems once i registered an object with luabind, im unable to reduce the memory usage to the same it was before registering. ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/