diff --git a/XIPivot.Ashita/plugin/AshitaInterface.cpp b/XIPivot.Ashita/plugin/AshitaInterface.cpp index 516b538..3ddc89f 100644 --- a/XIPivot.Ashita/plugin/AshitaInterface.cpp +++ b/XIPivot.Ashita/plugin/AshitaInterface.cpp @@ -658,6 +658,7 @@ namespace XiPivot imgui->LabelText(u8"allocation", "%.2fmb", stats.allocation / 1048576.0f); imgui->LabelText(u8"used size", "%.2fmb", stats.used / 1048576.0f); imgui->LabelText(u8"objects", "%d", stats.activeObjects); + imgui->LabelText(u8"ignored", "%d", stats.cacheIgnored); imgui->Separator(); imgui->LabelText(u8"next purge in", "%ds", m_nextCachePurge - time(nullptr)); diff --git a/XIPivot.Ashita/plugin/AshitaInterface.h b/XIPivot.Ashita/plugin/AshitaInterface.h index 75d0b96..ae1c4de 100644 --- a/XIPivot.Ashita/plugin/AshitaInterface.h +++ b/XIPivot.Ashita/plugin/AshitaInterface.h @@ -68,7 +68,6 @@ namespace XiPivot /* helpers for GUI config */ void renderOverlayConfigUI(IGuiManager* imgui); void renderMemCacheConfigUI(IGuiManager* imgui); - void renderAboutUI(IGuiManager* imgui); void renderCacheStatsUI(IGuiManager* imgui); std::vector listAvailableOverlays() const; diff --git a/XIPivot.Ashita/plugin/plugin.cpp b/XIPivot.Ashita/plugin/plugin.cpp index 176153d..032675b 100644 --- a/XIPivot.Ashita/plugin/plugin.cpp +++ b/XIPivot.Ashita/plugin/plugin.cpp @@ -42,7 +42,7 @@ extern "C" { strcpy_s(info->Name, sizeof(info->Name), "XIPivot"); info->InterfaceVersion = ASHITA_INTERFACE_VERSION; - info->PluginVersion = 0.46f; + info->PluginVersion = 0.47f; info->Priority = 0; } diff --git a/XIPivot.Ashita_v4/polplugin/AshitaInterface.h b/XIPivot.Ashita_v4/polplugin/AshitaInterface.h index 0a18fa1..614864e 100644 --- a/XIPivot.Ashita_v4/polplugin/AshitaInterface.h +++ b/XIPivot.Ashita_v4/polplugin/AshitaInterface.h @@ -39,7 +39,7 @@ namespace XiPivot { static constexpr auto PluginName = "pivot"; static constexpr auto PluginAuthor = "Heals"; - static constexpr auto PluginVersion = 4.1002; + static constexpr auto PluginVersion = 4.1104; static constexpr auto PluginUrl = "https://github.com/Shirk/XIPivot"; static constexpr auto PluginDescr = "Runtime DAT, sfx and bgm replacement manager."; static constexpr auto PluginCommand = "pivot"; diff --git a/XIPivot.Ashita_v4/polplugin/UserInterface.cpp b/XIPivot.Ashita_v4/polplugin/UserInterface.cpp index 999680a..bdb98cb 100644 --- a/XIPivot.Ashita_v4/polplugin/UserInterface.cpp +++ b/XIPivot.Ashita_v4/polplugin/UserInterface.cpp @@ -450,6 +450,7 @@ namespace XiPivot imgui->LabelText("allocation", "%.2fmb", stats.allocation / 1048576.0f); imgui->LabelText("used size", "%.2fmb", stats.used / 1048576.0f); imgui->LabelText("objects", "%d", stats.activeObjects); + imgui->LabelText("ignored", "%d", stats.cacheIgnored); imgui->Separator(); imgui->LabelText("next purge in", "%ds", m_cacheNextPurge - time(nullptr)); diff --git a/XIPivot.Core/src/MemCache.cpp b/XIPivot.Core/src/MemCache.cpp index e34a2d9..d024bbb 100644 --- a/XIPivot.Core/src/MemCache.cpp +++ b/XIPivot.Core/src/MemCache.cpp @@ -38,6 +38,9 @@ namespace XiPivot { /* static member initialisation */ + namespace { + static constexpr size_t sMaxCacheObjectSize = 104857599U; // 100MB -1byte + } MemCache* MemCache::s_instance = nullptr; MemCache::pFnReadFile MemCache::s_procReadFile = ReadFile; @@ -79,7 +82,7 @@ namespace XiPivot MemCache::MemCache() : m_hooksSet(false), - m_stats({ 0, 0, 0, 0, 0 }), + m_stats({ 0, 0, 0, 0, 0, 0 }), m_logDebug(ILogProvider::LogLevel::Discard) { m_logger = DummyLogProvider::instance(); @@ -214,6 +217,9 @@ namespace XiPivot ++it; } } + + m_stats.cacheIgnored = 0; + return objectsPurged; } @@ -270,12 +276,20 @@ namespace XiPivot return nullptr; } + size_t size = GetFileSize(hRef, nullptr); + if (size > sMaxCacheObjectSize) + { + /* do NOT cache objects above sMaxCacheObjectSize lower the risk of "blackouts" + * caused by XI running out of available memory */ + m_logger->logMessageF(ILogProvider::LogLevel::Debug, "getCachedObject: object size exceeds limit, no cache object created."); + ++m_stats.cacheIgnored; + return nullptr; + } + /* try and create a new object on the fly and store it */ CacheObject* obj = new (std::nothrow) CacheObject; if (obj != nullptr) { - size_t size = GetFileSize(hRef, nullptr); - if (m_stats.used + size <= m_stats.allocation) { memset(obj, 0, sizeof(CacheObject)); diff --git a/XIPivot.Core/src/MemCache.h b/XIPivot.Core/src/MemCache.h index 737daab..e04b6b3 100644 --- a/XIPivot.Core/src/MemCache.h +++ b/XIPivot.Core/src/MemCache.h @@ -92,6 +92,7 @@ namespace XiPivot unsigned cacheHits; unsigned cacheMisses; + unsigned cacheIgnored; unsigned activeObjects; }; diff --git a/XIPivot.Windower/lua/XIPivot.lua b/XIPivot.Windower/lua/XIPivot.lua index 74026db..295948e 100644 --- a/XIPivot.Windower/lua/XIPivot.lua +++ b/XIPivot.Windower/lua/XIPivot.lua @@ -28,7 +28,7 @@ _addon.name = 'XIPivot' _addon.author = 'Heals' -_addon.version = '0.4.6' +_addon.version = '0.4.7' _addon.command = 'pivot' config = require('config')