diff --git a/src/ui/windows/mining_earnings.cpp b/src/ui/windows/mining_earnings.cpp index 94f1d4e..186f23c 100644 --- a/src/ui/windows/mining_earnings.cpp +++ b/src/ui/windows/mining_earnings.cpp @@ -307,9 +307,20 @@ void RenderMiningEarnings(App* app, const WalletState& state, const MiningInfo& // ---- Memory bar — centered in remaining space below details ---- { - double totalRAM = dragonx::util::Platform::getTotalSystemRAM_MB(); - double usedRAM = dragonx::util::Platform::getUsedSystemRAM_MB(); - double selfRAM = dragonx::util::Platform::getSelfMemoryUsageMB(); + double totalRAM = dragonx::util::Platform::getTotalSystemRAM_MB(); // cached inside Platform + // Used/self RAM are synchronous OS reads (/proc/meminfo + /proc/self/status on Linux): sample them at + // most once a second, not every frame. The first frame after >1 s idle resamples immediately. + static double s_usedRAM = 0.0, s_selfRAM = 0.0; + static int64_t s_ramSampledMs = 0; + static bool s_ramSampled = false; + if (!s_ramSampled || IntervalElapsed(nowMs, s_ramSampledMs, 1000)) { + s_usedRAM = dragonx::util::Platform::getUsedSystemRAM_MB(); + s_selfRAM = dragonx::util::Platform::getSelfMemoryUsageMB(); + s_ramSampledMs = nowMs; + s_ramSampled = true; + } + double usedRAM = s_usedRAM; + double selfRAM = s_selfRAM; double daemonRAM = app->getDaemonMemoryUsageMB(); // Include xmrig memory when pool mining double xmrigRAM = state.pool_mining.memory_used / (1024.0 * 1024.0); // bytes -> MB