lua-users home
lua-l archive

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


> The EPOCLua version of iolib causes a "memory leak" of sorts: lua's iolib
> utilizes EPOC's STDLIB library, but there is no explicit call to (the OS
> function) CloseSTDLIB() before program-exit.  If STDLIB is used w/out a call
> to CloseSTDLIB() before your app is exited, then the app -may- leak memory.

I've ported Lua to EPOC, and I'm not an EPOC expert (indeed, the Lua port
was the first bit of non-OPL programming I'd done on EPOC), so I didn't know
about this problem.

I suppose that the obvious place to put the call to CloseSTDLIB() is in
lua_close(), but the Lua docs say that you don't have to call lua_close().

Also, in my port, Lua is supplied as a DLL, so will a call to CloseSTDLIB be
made in the correct context there, i.e. when an app calls lua_close() (which
is in a DLL), will it be that app's STDLIB context that is "finalised"?

In any case, I presume that if you have a normal C app compiled against the
library, it will implicitly call CloseSTDLIB when it exits, so doesn't need
this call (or worse, may crash if it's already been made).

Hence, lua.exe and luac.exe specifically *don't want* this call...

And what about OPL applications that use the Lua OPX? Where (if at all)
should CloseSTDLIB be called for them?

I'd appreciate some guidance on this. Also on when exactly the app will leak
memory, and how much. I've not noticed any memory leak on my Revo (I even
deleted MemFree a little while ago because in over a year of use it had
never found any memory to reclaim), but I could be missing something...

-- 
http://sc3d.org/rrt/ | art, n.  romanticized mundanity