lua-users home
lua-l archive

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

Lua 5.1 does unload modules. This happens at lua_close().
The reason why you need it in Win32 is for code like:

while (some condition) { /* runs for 2 months */
  L = lua_open();
  stuff();   /* calls lua_pcall */

If the pcall()ed code executes LoadLibrary() without executing FreeLibrary()
we may have a never ending increase in the number of open handles.
If the library being loaded is something like Luasocket which (for Win32)
needs to issue paired WSAStartup()/WSACleanup() calls this becomes
even more critical.

David B

Rici Lake wrote:
> Lua does not ever unload modules, so the "somehow" question here is
> pretty important :) Lua doesn't call luaopen_XXX automatically, either.

> But I'm still not convinced that unloading dynamic modules is a good
> idea