1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-06-19 13:11:32 +00:00

[Lua] Fix memory tracking

This commit is contained in:
Petr Mikheev 2023-02-26 16:50:17 +01:00
parent 2aac6abb85
commit d0a82437a4
2 changed files with 5 additions and 2 deletions

View file

@ -126,11 +126,14 @@ namespace LuaUtil
id = self->mActiveScriptIdStack.back(); id = self->mActiveScriptIdStack.back();
bigAllocDelta = nsize; bigAllocDelta = nsize;
} }
if (id.mContainer) if (id.mIndex >= 0)
{ {
if (static_cast<size_t>(id.mIndex) >= self->mMemoryUsage.size()) if (static_cast<size_t>(id.mIndex) >= self->mMemoryUsage.size())
self->mMemoryUsage.resize(id.mIndex + 1); self->mMemoryUsage.resize(id.mIndex + 1);
self->mMemoryUsage[id.mIndex] += bigAllocDelta; self->mMemoryUsage[id.mIndex] += bigAllocDelta;
}
if (id.mContainer)
{
id.mContainer->addMemoryUsage(id.mIndex, bigAllocDelta); id.mContainer->addMemoryUsage(id.mIndex, bigAllocDelta);
if (newPtr && nsize > smallAllocSize) if (newPtr && nsize > smallAllocSize)
self->mBigAllocOwners.emplace(newPtr, AllocOwner{ id.mContainer->mThis, id.mIndex }); self->mBigAllocOwners.emplace(newPtr, AllocOwner{ id.mContainer->mThis, id.mIndex });

View file

@ -23,7 +23,7 @@ namespace LuaUtil
struct ScriptId struct ScriptId
{ {
ScriptsContainer* mContainer = nullptr; ScriptsContainer* mContainer = nullptr;
int mIndex; // index in LuaUtil::ScriptsConfiguration int mIndex = -1; // index in LuaUtil::ScriptsConfiguration
}; };
struct LuaStateSettings struct LuaStateSettings