diff --git a/apps/openmw/engine.cpp b/apps/openmw/engine.cpp index 4641ed8520..9a7592b316 100644 --- a/apps/openmw/engine.cpp +++ b/apps/openmw/engine.cpp @@ -442,7 +442,9 @@ bool OMW::Engine::frame(float frametime) stats->setAttribute(frameNumber, "WorkQueue", mWorkQueue->getNumItems()); stats->setAttribute(frameNumber, "WorkThread", mWorkQueue->getNumActiveThreads()); - mEnvironment.reportStats(frameNumber, *stats); + mMechanicsManager->reportStats(frameNumber, *stats); + mWorld->reportStats(frameNumber, *stats); + mLuaManager->reportStats(frameNumber, *stats); } } catch (const std::exception& e) diff --git a/apps/openmw/mwbase/environment.cpp b/apps/openmw/mwbase/environment.cpp index 18b6589c9a..f2393f21c4 100644 --- a/apps/openmw/mwbase/environment.cpp +++ b/apps/openmw/mwbase/environment.cpp @@ -4,9 +4,6 @@ #include -#include "mechanicsmanager.hpp" -#include "world.hpp" - MWBase::Environment* MWBase::Environment::sThis = nullptr; MWBase::Environment::Environment() @@ -19,9 +16,3 @@ MWBase::Environment::~Environment() { sThis = nullptr; } - -void MWBase::Environment::reportStats(unsigned int frameNumber, osg::Stats& stats) const -{ - mMechanicsManager->reportStats(frameNumber, stats); - mWorld->reportStats(frameNumber, stats); -} diff --git a/apps/openmw/mwbase/environment.hpp b/apps/openmw/mwbase/environment.hpp index c2f4fd129c..8044c385a8 100644 --- a/apps/openmw/mwbase/environment.hpp +++ b/apps/openmw/mwbase/environment.hpp @@ -5,11 +5,6 @@ #include -namespace osg -{ - class Stats; -} - namespace Resource { class ResourceSystem; @@ -117,8 +112,6 @@ namespace MWBase assert(sThis != nullptr); return *sThis; } - - void reportStats(unsigned int frameNumber, osg::Stats& stats) const; }; } diff --git a/apps/openmw/mwlua/luamanagerimp.cpp b/apps/openmw/mwlua/luamanagerimp.cpp index 95da0e78c1..25a4c7f876 100644 --- a/apps/openmw/mwlua/luamanagerimp.cpp +++ b/apps/openmw/mwlua/luamanagerimp.cpp @@ -2,6 +2,10 @@ #include +#include + +#include "sol/state_view.hpp" + #include #include @@ -608,4 +612,9 @@ namespace MWLua mActionQueue.push_back(std::make_unique(&mLua, std::move(action), name)); } + void LuaManager::reportStats(unsigned int frameNumber, osg::Stats& stats) + { + const sol::state_view state(mLua.sol()); + stats.setAttribute(frameNumber, "Lua UsedMemory", state.memory_used()); + } } diff --git a/apps/openmw/mwlua/luamanagerimp.hpp b/apps/openmw/mwlua/luamanagerimp.hpp index 1146147acc..1d56c31af8 100644 --- a/apps/openmw/mwlua/luamanagerimp.hpp +++ b/apps/openmw/mwlua/luamanagerimp.hpp @@ -127,6 +127,8 @@ namespace MWLua bool isProcessingInputEvents() const { return mProcessingInputEvents; } + void reportStats(unsigned int frameNumber, osg::Stats& stats); + private: void initConfiguration(); LocalScripts* createLocalScripts(const MWWorld::Ptr& ptr, diff --git a/components/resource/stats.cpp b/components/resource/stats.cpp index 85e6a6bd8d..5ef1bf3e9a 100644 --- a/components/resource/stats.cpp +++ b/components/resource/stats.cpp @@ -463,6 +463,8 @@ namespace Resource "Physics Objects", "Physics Projectiles", "Physics HeightFields", + "", + "Lua UsedMemory", }); static const auto longest = std::max_element(statNames.begin(), statNames.end(),