I understand that this project support is in limbo but I still believe in the utility and that its something plugins could greatly benefit from so hopefully other believers can help me diagnose this issue :)
I was developing an independent plugin and noticed a memory leak. It seems related to invalidating the timeoutFunction when looping the Hermes JS engine.
I went ahead and tested the GainPlugin example and found a similar leak.
Profiled using leaks --atExit -- ./ReactJUCEGainPlugin on an M1 Mac.
I've narrowed down the problem code to EcmascriptEngine_Hermes.cpp and reviewed the clearing functionality and it all seems correct to me which makes me think that it could be some concurrency issue but I'm not entirely sure.
{
explicit TimeoutFunctionManager(jsi::Runtime &rt)
: runtime(rt)
{
}
~TimeoutFunctionManager() override
{
clear();
}
void clear()
{
std::for_each(timeoutFunctions.cbegin(), timeoutFunctions.cend(), [this](const auto &tf)
{ stopTimer(tf.first); });
timeoutFunctions.clear();
}
jsi::Value clearTimeout(const int id)
{
stopTimer(id);
if (const auto f = timeoutFunctions.find(id); f != timeoutFunctions.cend())
timeoutFunctions.erase(f);
return jsi::Value();
}
jsi::Value newTimeout(jsi::Function f, const int timeoutMillis, std::vector<jsi::Value> args, const bool repeats = false)
{
static int nextId = 0;
timeoutFunctions.emplace(nextId, TimeoutFunction(std::move(f), std::move(args), repeats));
startTimer(nextId, timeoutMillis);
return nextId++;
Any one experienced or with more knowledge than me have any clues? Any help is appreciated
Hi!
I understand that this project support is in limbo but I still believe in the utility and that its something plugins could greatly benefit from so hopefully other believers can help me diagnose this issue :)
I was developing an independent plugin and noticed a memory leak. It seems related to invalidating the
timeoutFunction
when looping the Hermes JS engine.I went ahead and tested the GainPlugin example and found a similar leak.
Profiled using
leaks --atExit -- ./ReactJUCEGainPlugin
on an M1 Mac.I've narrowed down the problem code to
EcmascriptEngine_Hermes.cpp
and reviewed the clearing functionality and it all seems correct to me which makes me think that it could be some concurrency issue but I'm not entirely sure.Any one experienced or with more knowledge than me have any clues? Any help is appreciated