MCPcopy Create free account
hub / github.com/MergHQ/CRYENGINE / ForceGarbageCollection

Method ForceGarbageCollection

Code/CryEngine/CryScriptSystem/ScriptSystem.cpp:1805–1837  ·  view source on GitHub ↗

///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////

Source from the content-addressed store, hash-verified

1803//////////////////////////////////////////////////////////////////////
1804//////////////////////////////////////////////////////////////////////
1805void CScriptSystem::ForceGarbageCollection()
1806{
1807 int beforeUsage = lua_gc(L, LUA_GCCOUNT, 0) * 1024 + lua_gc(L, LUA_GCCOUNTB, 0);
1808
1809 // Do a full garbage collection cycle.
1810 lua_gc(L, LUA_GCCOLLECT, 0);
1811
1812 int fracUsage = lua_gc(L, LUA_GCCOUNTB, 0);
1813 int totalUsage = lua_gc(L, LUA_GCCOUNT, 0) * 1024 + fracUsage;
1814
1815#if USE_RAW_LUA_ALLOCS
1816 // Nothing to do.
1817 #ifdef USE_GLOBAL_BUCKET_ALLOCATOR
1818 gLuaAlloc.cleanup();
1819 #endif
1820#endif
1821
1822 CryComment("Lua garbage collection %i -> %i", beforeUsage, totalUsage);
1823
1824 /*char sTemp[200];
1825 lua_StateStats lss;
1826 lua_getstatestats(L,&lss);
1827 cry_sprintf(sTemp,"protos=%d closures=%d tables=%d udata=%d strings=%d\n",lss.nProto,lss.nClosure,lss.nHash,lss.nUdata,lss.nString);
1828 OutputDebugString("BEFORE GC STATS :");
1829 OutputDebugString(sTemp);*/
1830
1831 //lua_setgcthreshold(L, 0);
1832
1833 /*lua_getstatestats(L,&lss);
1834 cry_sprintf(sTemp,"protos=%d closures=%d tables=%d udata=%d strings=%d\n",lss.nProto,lss.nClosure,lss.nHash,lss.nUdata,lss.nString);
1835 OutputDebugString("AFTER GC STATS :");
1836 OutputDebugString(sTemp);*/
1837}
1838
1839//////////////////////////////////////////////////////////////////////
1840//////////////////////////////////////////////////////////////////////

Callers 5

LoadLevelMethod · 0.80
PrepareNextLevelMethod · 0.80
ResetEngineMethod · 0.80
LoadGameMethod · 0.80
LuaGarbargeCollectFunction · 0.80

Calls 2

CryCommentFunction · 0.85
cleanupMethod · 0.45

Tested by

no test coverage detected