Project/06 - External/KopiLuaInterface/src/Lua.cs
/// <summary>
/// Consider garbage-collecting stale Lua references at this point.  We only go ahead if enough Lua 
/// references have been allocated since the last collection - the overhead in the interpreter per 
/// reference is very small so we can wait quite a long time before worrying that most of the references
/// are stale.
/// </summary>
Consider garbage-collecting stale Lua references at this point.  We only go ahead if enough Lua
references have been allocated since the last collection - the overhead in the interpreter per
reference is very small so we can wait quite a long time before worrying that most of the references
are stale.
Consider garbage - collecting stale Lua references at this point . We only go ahead if enough Lua references have been allocated since the last collection - the overhead in the interpreter per reference is very small so we can wait quite a long time before worrying that most of the references are stale .
private void CollectGarbage()
        {
            if (_luaRefToCsObj.Count < _nextGcNumRefs - LuaRefGcGranularity)
                _nextGcNumRefs = _luaRefToCsObj.Count + LuaRefGcGranularity;
            if (_luaRefToCsObj.Count < _nextGcNumRefs)
                return;
            _deadLuaRefs.Clear();
            foreach (var luaRef in _luaRefToCsObj.Keys)
            {
                if (!_luaRefToCsObj[luaRef].IsAlive)
                {
                    _deadLuaRefs.Add(luaRef);
                }
            }
            foreach (var luaRef in _deadLuaRefs)
            {
                dispose(luaRef);
                _luaRefToCsObj.Remove(luaRef);
            }
            _deadLuaRefs.Clear();
            _nextGcNumRefs = _luaRefToCsObj.Count + LuaRefGcGranularity;
        }
private void CollectGarbage ( ) { if ( _luaRefToCsObj . Count < _nextGcNumRefs - LuaRefGcGranularity ) _nextGcNumRefs = _luaRefToCsObj . Count + LuaRefGcGranularity ; if ( _luaRefToCsObj . Count < _nextGcNumRefs ) return ; _deadLuaRefs . Clear ( ) ; foreach ( var luaRef in _luaRefToCsObj . Keys ) { if ( ! _luaRefToCsObj [ luaRef ] . IsAlive ) { _deadLuaRefs . Add ( luaRef ) ; } } foreach ( var luaRef in _deadLuaRefs ) { dispose ( luaRef ) ; _luaRefToCsObj . Remove ( luaRef ) ; } _deadLuaRefs . Clear ( ) ; _nextGcNumRefs = _luaRefToCsObj . Count + LuaRefGcGranularity ; }
Consider garbage-collecting stale Lua references at this point.
Consider garbage - collecting stale Lua references at this point .
// Reduce the reference count target if the actual number of references has somehow decreased // Don't collect now if we haven't yet reached the reference count target // Gather the list of dead refs // Dispose the dead refs and free the entries in _luaRefToCsObj // Set the reference count target for the next collection