lua-users home
lua-l archive

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


> One simple way to do this would be to keep a list of module handles in a table 
> stored in the registry.  The current __gc meta-method on the module's handle 
> would need to be removed.  When the Lua state is being closed first process 
> all finalizers, then go through the list of module handles unloading each one 
> (in reverse order maybe?).

This is more or less what we have done in the end. The table has its
own __gc metamethod, which traverses it unloading all handles. Because
the table is created in the beginning of the program (when 'package' is
opened), its __gc will run after all user-created __gc's.


> This will not support dynamic unloading of modules, only unloading when 
> closing a Lua State.

This is already true in standard Lua.

-- Roberto