lua-users home
lua-l archive

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


Am 09.10.2013 22:43 schröbte Geoff Smith:
Hi


Hi!


  language = nil   -- I was expecting this to free most of my memory

  collectgarbage("collect")

So that big table in the require file is likely not being freed totally by the garbage collection. I don't understand why that is happening

Any thoughts or explanation would be appreciated

The value returned by a call to `require` is cached in the `package.loaded` table (or `debug.getregistry()._LOADED`, which is the same table), so that a second call to `require` doesn't have to load the Lua module again. You can do

    language = nil
    package.loaded.frenchBig = nil
    collectgarbage("collect")

if you really want to get rid of the frenchBig data. `dofile` doesn't do any caching, so

    dofile( assert( package.searchpath( "frenchBig", package.path ) ) )

would be an alternative to `require` if you don't want caching at all ...


Thanks

Geoff


HTH,
Philipp