From 413567e81fa89157ffab49635b9f1fa68e6d9b0d Mon Sep 17 00:00:00 2001 From: Vadim Zubkov Date: Mon, 16 Dec 2024 13:50:12 +0300 Subject: [PATCH] Merge pull request #336 from altmp/feature/js-timers-leak Fix js-module timers leak --- shared/V8ResourceImpl.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/shared/V8ResourceImpl.cpp b/shared/V8ResourceImpl.cpp index 2861779d..cf0a64f0 100644 --- a/shared/V8ResourceImpl.cpp +++ b/shared/V8ResourceImpl.cpp @@ -77,7 +77,16 @@ void V8ResourceImpl::OnTick() for(auto& nextTickCb : nextTickCallbacks) nextTickCb(); nextTickCallbacks.clear(); - for(auto& id : oldTimers) timers.erase(id); + for(auto& id : oldTimers) + { + auto it = timers.find(id); + if(it == timers.end()) + continue; + + auto timer = it->second; + timers.erase(it); + delete timer; + } oldTimers.clear();