lua-users home
lua-l archive

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



On Wed, Mar 3, 2010 at 5:22 AM, Kenneth LO <kenlo88@gmail.com> wrote:
So lua_close is the problem.  Just a quick change to loslib.c

More precisely, the absence of a call to lua_close.
 

static int os_exit (lua_State *L) {
 int t = luaL_optint(L, 1, EXIT_SUCCESS);
 lua_close(L);
 /* exit(luaL_optint(L, 1, EXIT_SUCCESS)); */
 exit(t);
}

So far it does the job but I'm not sure if there is any memory
leakage.  The manual says it will free all memory associated with the
state but does it include those locked in COM and OLE?  

It will call all __gc methods, free all memory, etc. What that means to COM and OLE stuff is that your objects will be released (that is, a call to IUnknown->Release). If your reference counting is correct, those instances will go away, else they won't.

Anyway, I presume that even with your patch, you may experience additional trouble. IIRC exit() does some housekeeping and then calls TerminateProcess() (we´re talking Windows here). So no DllMain calls for LuaCom and no CoUninitialize. That´s not good.