lua-users home
lua-l archive

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

> More than these things, it was my thought that using require 
> may be preventing garbage collection of my initialisation 
> code, since the closure created from the file is stored in 
> package.loaded. At least that is my understanding of it. I 
> checked in the C code and package.loaded does not have weak 
> values, so it must be preventing collection. For a package 
> that lots of code needs to use this is probably a good thing, 
> but for my code that needs to run once only it might be less 
> good, particularly as this is running on mobile phones.

This is hardly a surprise, but my understanding of the effects of
require was quite wrong.

Provided my initialisation files declare all data as local and don't
return anything, then everything will get collected nicely (except for
those items that are stored elsewhere and are actually needed later).

And for those files that may change during the life of the program and
therefore may need reloading, my unrequire function does the trick.

Thanks for listening to me babble while I sort things out :-)

- DC