Hi,
I have completed my first JUCE product and I was met with a final boss: A memory leak.
I noticed that my application gobbles up RAM more and more the longer it runs, and after about 3 weeks of testing, I ruled out that it’s not my frontend, so it has to be the backend.
I created a brand new WebView project with the original JUCE WebView example and I ran the following command in the frontend dev console:
for (var i = 0; i < 100000; i++) window.__JUCE__.backend.emitEvent("__juce__invoke", { name: "sayHello", params: ['JUCE'], resultId: i})
What happens is that RAM usage goes up a lot (expected) and then drop down (also expected) but the RAM does not fall down to pre-execution of the above code.
This means that every time a nativeAction is called, it returns with a tiny amount of RAM being eaten.
This eventually causes the JUCE app to freeze completely.
The app starts with 57MB, and after running the command it ends with 93MB. SO everytime I run this test, the app eats 37MB of RAM.
It shouldn’t do this.
This is a big problem when sending data from backend to frontend frequently continously, which is what my app does, because it continously needs data to update parts of the UI.
Can anyone look into this and tell me how to fix this?
Thank you