mirror of
https://github.com/Kelsidavis/WoWee.git
synced 2026-03-22 23:30:14 +00:00
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:
parent
4bd237b654
commit
2b99011cd8
2 changed files with 12 additions and 0 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -2539,6 +2539,8 @@ void GameHandler::handlePacket(network::Packet& packet) {
|
|||
poi.icon = icon;
|
||||
poi.data = data;
|
||||
poi.name = std::move(name);
|
||||
// Cap POI count to prevent unbounded growth from rapid gossip queries
|
||||
if (gossipPois_.size() >= 200) gossipPois_.erase(gossipPois_.begin());
|
||||
gossipPois_.push_back(std::move(poi));
|
||||
LOG_DEBUG("SMSG_GOSSIP_POI: x=", poiX, " y=", poiY, " icon=", icon);
|
||||
break;
|
||||
|
|
@ -21031,6 +21033,7 @@ void GameHandler::handleQuestPoiQueryResponse(network::Packet& packet) {
|
|||
poi.name = questTitle.empty() ? "Quest objective" : questTitle;
|
||||
LOG_DEBUG("Quest POI: questId=", questId, " mapId=", mapId,
|
||||
" centroid=(", poi.x, ",", poi.y, ") title=", poi.name);
|
||||
if (gossipPois_.size() >= 200) gossipPois_.erase(gossipPois_.begin());
|
||||
gossipPois_.push_back(std::move(poi));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue