lua-users home
lua-l archive

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

> > You cannot set __gc for tables. But you can say use a udata as upvalue for
> > all functions registered in the module and then clean up when that udata
> > is collected.
> I have also thought about what to do in this situation and I am still
> learning these tricks. Any examples would be very helpful. Thanks.

See loadlib.c, which sets __gc for library handles to tell the OS to
unload libraries from the app when they become garbage in Lua. This is
not the same technique I described above, though.