fix: cap gossipPois_ vector growth and add soft frame rate limiter

Cap gossipPois_ at 200 entries (both gossip POI and quest POI paths) to
prevent unbounded memory growth from rapid gossip/quest queries. Add soft
240 FPS frame rate limiter when vsync is off to prevent 100% CPU usage —
sleeps for remaining frame budget when frame completes in under 4ms.
This commit is contained in:
Kelsi 2026-03-20 18:51:05 -07:00
parent 4bd237b654
commit 2b99011cd8
2 changed files with 12 additions and 0 deletions

View file

@ -646,6 +646,15 @@ void Application::run() {
LOG_ERROR("GPU device lost — exiting application");
window->setShouldClose(true);
}
// Soft frame rate cap when vsync is off to prevent 100% CPU usage.
// Target ~240 FPS max (~4.2ms per frame); vsync handles its own pacing.
if (!window->isVsyncEnabled() && deltaTime < 0.004f) {
float sleepMs = (0.004f - deltaTime) * 1000.0f;
if (sleepMs > 0.5f)
std::this_thread::sleep_for(std::chrono::microseconds(
static_cast<int64_t>(sleepMs * 900.0f))); // 90% of target to account for sleep overshoot
}
}
} catch (...) {
watchdogRunning.store(false, std::memory_order_release);