• Stephen Toub's avatar
    Fix finalizability of Lua instances (#531) · 012d69a7
    Stephen Toub authored
    * Fix finalizability of Lua instances
    
    Lua instances end up being permanently rooted until Dispose is explicitly called, because the ctor roots the Lua instance into a static singleton of ObjectTranslatorPool. This fixes it by replacing the ConcurrentDictionary with a ConditionalWeakTable, in order to avoid the pool keeping a strong reference to the LuaState / Lua objects.
    
    * Try an alternate approach
    
    Instead of having the ObjectTranslatorPool store weak references, which means LuaState objects might get collected when still referenced by native code, have the ObjectTranslator store a weak rather than strong reference to the Lua object, which is what has the finalizer.
    
    * Disable test on mono
    012d69a7
ObjectTranslatorPool.cs 1.34 KB