How to drop all code and memory space of a Lua module

前端 未结 2 386
予麋鹿
予麋鹿 2021-01-25 01:35

I have a long time fly program, it is a player. After it started, it will load and run Lua code from net by the server\'s command. Each code have a unique named module.

2条回答
  •  日久生厌
    2021-01-25 02:22

    Module in Lua is just another table with all the functions and variables inside. If you set it to nil and remove the entry in package.loaded it should be cleaned by the garbage collector.

    Here's a function implementing module unloading: http://lua-users.org/lists/lua-l/2009-03/msg00587.html

提交回复
热议问题