Jesus the memory leak in 1.04 modded is insane thing eats like 6 gigs of ram after idk 10 min fix it please
First, let's talk about what a memory leak is and what it is not.
A memory leak is where a block of memory is allocated, used, and then discarded but never given back to the system.
This is a major problem with c/c++ programs, because it is up to the program to manage the memory entirely where as, in JavaScript, there's what's called reference counting. Basically the engine looks at everyone who's using a variable, and when no one is using it any more, it is removed.
This is called garbage collection and generally happens automatically, which can be bad for a game. (Garbage collection takes processor power and if you're trying to render an animation at the time, it can cause skips and jumps.) As such garbage collection is usually run once your free memory drops below a certain point. (This is known as memory pressure.) You can read up on more details here:
You must be registered to see the links
There's long boring explanations as to what this means and in what corner cases garbage collection can fail, but the upshot is, it is really hard to have a memory leak in JavaScript, but very easy to have one in a program like Chrome.
The way the RPG Maker MV (and later) works is it is using NW.js (which is basically a version of the Chrome core) and some JavaScript files. In this case we're talking about going from Chromium
You must be registered to see the links
to
You must be registered to see the links
. That's a pretty major jump. At the same time this required a change in Pixi.js.
Now the very latest Chromium with NW.js is
You must be registered to see the links
and the latest version (as of today) is
You must be registered to see the links
.
So here's the bad news. Between Chromium 65 and 81, and the change to Pixi.js the browser starts to eat memory. Chromium is known to eat memory, in fact there are even meme's about it.
You must be registered to see the links
Also, it seems this a bigger problem on Windows. Here's what it looked like after 20 minutes of running on Linux:
The reason NW.js was updated was to handle issues with video playback.
I had updated to NW.js v0.45.6 because starting with NW.js v0.46.0 and later, there was significant input lag. As of version 0.50.2 this appears to be fixed. Furthermore the memory usage is significantly lower:
Also, with this new version comes a new JavaScript memory visualization tool. That is pointing to an issue with Pixi.js creating and holding on to textures. It looks like it is caching things in case they are reused, even when it doesn't make sense. I will look at what needs to happen to fix that, possibly on scene change to limit the impact of garbage collection.