lua-users home
lua-l archive

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


> QUESTION:
> I suspect that the cleanup of the garbage collector (in the last phase  
> of execution) occurs in the order in which the objects are encountered. 
> If so, it is detrimental if the order of unloading is critical, as is the 
> case here.
> I expected that the parent module ioio (not yet unloaded) and having the 
> iom table in its environment, would prevent early unloading even in the 
> final cleanup; clearly that is not true. However, I fail to see why the 
> iom module could be marked eligible for gc'ing while still held by its 
> parent ioio? Is the library perhaps some other object than the table 
> granting access to it? I am not versed enough in matters of library 
> loading to answer that question.
> Is my analysis correct?

In the cleanup phase, references do not prevent a module from being
finalized; otherwise the clean up would be a regular collection and
would not collect everything. However, finalizers are not called in
arbitrary order, but in reverse order of their creation. If module A
is loaded before module B (so that B may depend on A), then module A
will be unloaded after module B.

-- Roberto