FPS Dropping Over Time

Hi folks,

My game generally runs at a very smooth 59-61 FPS with no issues at all.

However, over time, as I load more maps and do more things, I start getting frame drops. These drops start out by just going to 58 frames, but over time it will go as low as into the 40s, which cause noticeable stutters that are very jarring when the player is moving quickly.

Sometimes, if I let the game sit idle, these drops will sort themselves out, but sometimes the game will be running fine, and letting it idle will gradually cause these drops to start happening even when nothing is changing in the game.

Restarting the game almost always fixes this until it "builds up" again, so whatever causes it isn't something being saved like events etc.

I used to have some plugins installer (such as VisuStella Events Move Core) which caused lag, but since removing them, things are generally stable.

Is there anything that could be causing these gradual frame drops? I have some large sprite sheets, and am using parallax mapping, but my game is 16x16, so even loading a "large" image for me is 1/3 of a typical game.

I have very few parallel events, just one that runs once per in-game day (20 irl mins), and one that runs once per hour (1 irl min), but does nothing unless some very specific conditions are met. Either way, these frame drops are happening much more regularly than these would be running, and seem to "build up".

This occurs on multiple devices, and I have updated pixi.js to v6 and nwjs to v70 (highest SteamDeck compatible).

Here are my plugins:
plugins 1.JPG

plugins 2.JPG

plugins 3.JPG


Thanks!
If it's lowering over time, that would suggest to me that you have a memory leak somewhere, such as sprites that are being created but not destroyed, and they're hogging more and more of your resources as you progress through the game.
If it's lowering over time, that would suggest to me that you have a memory leak somewhere, such as sprites that are being created but not destroyed, and they're hogging more and more of your resources as you progress through the game.

Something like this had occurred to me, but is it even possible in RPG Maker? The only way I am using sprites really is as event images, and changing event images with "Set Move Route" commands, which only affect them until the event is unloaded on map change AFAIK.
Something like this had occurred to me, but is it even possible in RPG Maker? The only way I am using sprites really is as event images, and changing event images with "Set Move Route" commands, which only affect them until the event is unloaded on map change AFAIK.
It's entirely possible. I actually had a commission to eliminate memory leaks in a VX Ace project where we found a *lot* of non-disposed sprites that were causing the game to slow down and eventually crash.
It's entirely possible. I actually had a commission to eliminate memory leaks in a VX Ace project where we found a *lot* of non-disposed sprites that were causing the game to slow down and eventually crash.

How would I even go about identifying these leaks and addressing them?
You have way too many plugins for me to read individually...are any of them "preloaders"? Those are primary culprits for memory leaks if not used very carefully.
You have way too many plugins for me to read individually...are any of them "preloaders"? Those are primary culprits for memory leaks if not used very carefully.

No, no preloaders.

The only plugin-related things I can think of would be "Community Lighting", as I know lighting in general can slow things down, "GalvLayerGraphics" in case it is a parallax mapping problem, and maybe "DT_GameTime" if that it somehow using too many resources to increment the time and flip some of my time-based switches. Other than that, maybe some VisuStella weirdness.

Everything else is pretty benign. Just things to modify simple visual things, and trigger events under diff circumstances, give events self-variables, have bigger events, etc.

The main confusing thing is that everything starts out fine, and the lag only shows up after a while of playing.
Well, depending on how long it takes for the lag to become evident, you can do some troubleshooting; turn off half your plugins, save, start a new game, see if it lags. Swap with the other half. Narrow it down.

Or Trihan may have some more technical suggestions.
Ironically this is one area where VX Ace has an advantage over MV/MZ, because there was a script for that which identified undisposed bitmaps and made tracking down rogue sprites a lot easier. I'm not sure how easy it would be to create such a tool in Javascript.
"DT_GameTime" if that it somehow using too many resources to increment the time and flip some of my time-based switches.
Given the other conversation about the smelting, I'd review that conversation and this topic and see if the logic can apply elsewhere. If you have something tracking time and flipping switches places where you are not, you might be accumulating a lot of things you're not realizing. See if you can move some of those items to the same idea we talked about in the smelting, where you're not always tracking the thing, you just check the thing/timestamp when you arrive on a relevant map.
The only plugin-related things I can think of would be "Community Lighting", as I know lighting in general can slow things down, "GalvLayerGraphics" in case it is a parallax mapping problem,
Try disabling community lighting first.
@woootbm was using it in his project (granted, an MV not MZ) project and it caused some major frame drops. The only difference here is that it would happen spontaneously, not gradually. Still it would be my first starting point anyways.

The thing is, both of these are likely to affect the game's performance at run time, but not cause memory leaks.

Usual copy-pasta about the engines performance:
Spoiler: Copy-pasta
RPG Maker is a single-core/single-threaded, and MV is a 32 bit application (MZ is 64 bit: wowee!), but both woefully under utilizes the GPU.
Doesn't matter how much ram or how many cores/threads your super CPU has as the application cannot take advantage of that. Everything is running on a single thread, so things can quickly bottleneck. Because of its single-core/single-thread preference, RM likes fast CPUs, not multi-core CPUs.

So, while the memory leak seems the most plausible, I would actually say some ill formed logic could also begin to slow things down.
Review your events. If you have parallel events running, make sure to optimize them. Include wait frames. Most parallel events don't need to run every frame. In fact, most can wait 4 or 5 frames.
Given the other conversation about the smelting, I'd review that conversation and this topic and see if the logic can apply elsewhere. If you have something tracking time and flipping switches places where you are not, you might be accumulating a lot of things you're not realizing. See if you can move some of those items to the same idea we talked about in the smelting, where you're not always tracking the thing, you just check the thing/timestamp when you arrive on a relevant map.

I think this should be fine as-is, since it actually is set up quite a bit like the smelting system. It updates only at midnight, and there is a loading screen for that. The events etc. don't actually do anything until the farm map is loaded.

Try disabling community lighting first.
@woootbm was using it in his project (granted, an MV not MZ) project and it caused some major frame drops. The only difference here is that it would happen spontaneously, not gradually. Still it would be my first starting point anyways.

The thing is, both of these are likely to affect the game's performance at run time, but not cause memory leaks.

Usual copy-pasta about the engines performance:
Spoiler: Copy-pasta
RPG Maker is a single-core/single-threaded, and MV is a 32 bit application (MZ is 64 bit: wowee!), but both woefully under utilizes the GPU.
Doesn't matter how much ram or how many cores/threads your super CPU has as the application cannot take advantage of that. Everything is running on a single thread, so things can quickly bottleneck. Because of its single-core/single-thread preference, RM likes fast CPUs, not multi-core CPUs.

So, while the memory leak seems the most plausible, I would actually say some ill formed logic could also begin to slow things down.
Review your events. If you have parallel events running, make sure to optimize them. Include wait frames. Most parallel events don't need to run every frame. In fact, most can wait 4 or 5 frames.

My game's overall performance does increase if I remove the Community Lighting plugin, but more in the sense that it goes from 59-61 average framerate to 60-61. It doesn't change the larger frame drop spikes that gradually appear. It was one of my first thoughts as well, but lighting is pretty important in my game and I've found this to actually be the fastest out of the ones I've tried.

I have included wait frames in my parallel events, but really I don't have many at all. There are a small handful that run once when a certain action happens, but nothing that is really "running" generally, apart from a plugin that is incrementing a time system.
How would I even go about identifying these leaks and addressing them?
One is to take notes. It can be mental or physical, but you need to track down every insignificant detail because they will add up and make it easier to narrow down the problem.

First step is to boot the game and stay on the title screen. Take note if the FPS problems get worse over time. It very likely doesn't but even taking note if the problem exists on the title screen is an important step.

Second step is to go to a map with no events at all. Take note if FPS rates go down over time. If it doesn't you can now rule out that the memory leak is not tied to that map. If a memory leak does occur, you now know your memory leak is not event related.

Third step is to go back and forth between two maps that are potentially suspect. Take note if the memory leaks occur. If there's no memory leak, try a different set of maps.

Fourth step is to also stay on any maps you discover are potentially suspect.

Fifth step is to disable all events on any map you discover are suspect and see if it narrows down to any specific event.

EDIT:* Essentially, the strategy is to gather as much data points and isolate your variables. That way, it is possible to narrow down your performance issues.

This is legit detective work and you need to creatively apply these broad strategies to narrow down your problem. This isn't like legos where you can follow the instructions to build a perfect lego house, because a situation like this might require us building that house on an odd terrain, if that makes sense.
I noticed you have a more current version of Battle Core than I do (1.8.0) but many of your other VS plugins are a few versions out of date compared to what I'm using. For instance I did a mass update of all VS plugins a couple months ago and Battle Core is 1.7.9 for me and Skill States Core is 1.4.2 but you are running 1.8.0 Battle Core with 1.4.0 Skillstatescore.

In other words you got a newer battle core with an older skillstatescore.

You got other similar mismatches going on with your VS plugins too.

I'd suggest updating all of your VS plugins too, or at least make sure they are all from the same release period.

Edit: While you are at it, you can set things to preload in VS plugins, check all your settings and see what you got set there. By default I think it preloads a few things.
One is to take notes. It can be mental or physical, but you need to track down every insignificant detail because they will add up and make it easier to narrow down the problem.

First step is to boot the game and stay on the title screen. Take note if the FPS problems get worse over time. It very likely doesn't but even taking note if the problem exists on the title screen is an important step.

Second step is to go to a map with no events at all. Take note if FPS rates go down over time. If it doesn't you can now rule out that the memory leak is not tied to that map. If a memory leak does occur, you now know your memory leak is not event related.

Third step is to go back and forth between two maps that are potentially suspect. Take note if the memory leaks occur. If there's no memory leak, try a different set of maps.

Fourth step is to also stay on any maps you discover are potentially suspect.

Fifth step is to disable all events on any map you discover are suspect and see if it narrows down to any specific event.

EDIT:* Essentially, the strategy is to gather as much data points and isolate your variables. That way, it is possible to narrow down your performance issues.

This is legit detective work and you need to creatively apply these broad strategies to narrow down your problem. This isn't like legos where you can follow the instructions to build a perfect lego house, because a situation like this might require us building that house on an odd terrain, if that makes sense.

These are good tips, thanks! Will start doing this.

I noticed you have a more current version of Battle Core than I do (1.8.0) but many of your other VS plugins are a few versions out of date compared to what I'm using. For instance I did a mass update of all VS plugins a couple months ago and Battle Core is 1.7.9 for me and Skill States Core is 1.4.2 but you are running 1.8.0 Battle Core with 1.4.0 Skillstatescore.

In other words you got a newer battle core with an older skillstatescore.

You got other similar mismatches going on with your VS plugins too.

I'd suggest updating all of your VS plugins too, or at least make sure they are all from the same release period.

Edit: While you are at it, you can set things to preload in VS plugins, check all your settings and see what you got set there. By default I think it preloads a few things.

Thanks for pointing that out - I've updated all the plugins to the current versions. I didn't have any of the pre-loading options enabled, so I don't think that was it.
In the console (F8 during gameplay) under the network tab, are there any assets that keep building up? Don't forget about your ms response (F2 for fps, press it again for ms - it shouldn't be higher than 3-5ms).

I would also check your nwjs to make sure you downloaded the 64-bit version (x64, not ia32) and keep track of the task manager for buildup in between map transfers.

Dynamic audio (OC RAM) or anything that is constantly checking player/map/event positions can build up as well, though not as much as images/videos.

Have you optimized your png files for parallax? Maybe reducing the bits to 8 (optimized palette) might be worth it if you are okay with that and it doesnt completely mess with the photo. I think some websites can optimize it as well but just make sure it is not distorting your parallax images.

Just ruling things out here - what are your computer specs?

Edit: I would use the console(F8) and check your network tab to make sure that it is not loading the same assets over and over again. I checked mine and found that it was loading a new instance of an image/audio that has already been loaded. Make sure it's not trying to do the same with your images/audio because it sounds like instead of referencing what is already loaded, it is loading that same image/audio as a new file.

I used Chaucer's Scene Stabilizer and ScS's BetterAudio to fix this issue, though, I am unaware of other MZ plugins that are similar - I am sure they are out there.
In the console (F8 during gameplay) under the network tab, are there any assets that keep building up? Don't forget about your ms response (F2 for fps, press it again for ms - it shouldn't be higher than 3-5ms).

I would also check your nwjs to make sure you downloaded the 64-bit version (x64, not ia32) and keep track of the task manager for buildup in between map transfers.

Dynamic audio (OC RAM) or anything that is constantly checking player/map/event positions can build up as well, though not as much as images/videos.

Have you optimized your png files for parallax? Maybe reducing the bits to 8 (optimized palette) might be worth it if you are okay with that and it doesnt completely mess with the photo. I think some websites can optimize it as well but just make sure it is not distorting your parallax images.

Just ruling things out here - what are your computer specs?

Edit: I would use the console(F8) and check your network tab to make sure that it is not loading the same assets over and over again. I checked mine and found that it was loading a new instance of an image/audio that has already been loaded. Make sure it's not trying to do the same with your images/audio because it sounds like instead of referencing what is already loaded, it is loading that same image/audio as a new file.

I used Chaucer's Scene Stabilizer and ScS's BetterAudio to fix this issue, though, I am unaware of other MZ plugins that are similar - I am sure they are out there.

Thanks for these tips - very helpful!

I didn't know about the ms toggle. Looking at that has helped a lot in narrowing down the issues. I was ranging from 5-8, and when the spikes occurred, it shot up to 12-17ms. A lot of latency!

I narrowed down a few culprits so far. The lighting plugin was (expectedly) contributing a bit, so I cut down on the lighting effects a bit. This helped a small amount.

The time plugin does add a noticeable amount of latency, however I am married to it at this point (and any time system is probably going to have this problem), so I have chosen to keep it as-is and look for performance boosts elsewhere. I did mess with its parameters though to make sure I didn't have it set up in a way that was particularly laggy.

The final (and most painful) find was that, once again, VisuStella plugins just suck for performance. Disabling a number of very benign VS plugins (even the "One-Time Purchase" plugin and a "Horror Effects" plugin that wasn't even doing anything) all gave slight ms improvements.

The big one though was the VS Quest Tracker plugin. It was contributing heavily to the spikes, and I went from 5-7 average and 12-17 spiked ms to 3-4 average and 6-8 spiked ms when I removed it.

Needless to day, I am cutting that plugin, and am re-working all of my quests to use CGMZ Quest Tracker instead. Luckily, I only have 12 quests to port over, so it will probably only be a day of work.

I have also used a lossless PNG optimizer to optimize all of my parallax images and sprite sheets. This cut file sizes from 5-75% depending on the image, with no loss of quality. (I used PNGGauntlet for this).

I think there is still some optimizing to go, as the spikes are still technically there, just much smaller now, but if I want this game to run well on lower-end devices (like Steam Deck, which is a priority for me), then I think I still need to make some more improvements.

For those asking about my PC specs:
specs.JPG
For those asking about my PC specs:
View attachment 292062
Are you set to using 'webgl' as well? I dont know about MZ but MV has a setting for it - MZ might be automatic. Your system should be able to handle it.

I'm not familiar with how the specific time system works but if you need it, you need it. I just did a small timing system for myself just to keep track of things (min, hr, day, week, mo, year) and it updates every 60 frames - so far, it gets the job done. Maybe I'll add seasons and a day system, too. Hopefully the timing system you use can be calibrated.

Glad you were able to resolve some issues. hope it works out for the best!
What can you tell us about your time functions?
I'm using a very simply one myself; parallel common event adds 1 to a counter every 180 frames, IE 3 seconds in-game is one "minute" in my world time.
I have a Unix timestamp stored as a parameter and, to get my "current" time, I add the var to my timestamp and use Javascript's built-in timestamp interpreting code. Functions for it are dead simple wrappers for the JS calls. With that, I'm essentially handling full time; minutes, hours, days, weeks, months, years. Using logic like we discussed over your smelting functions, I can do pretty much any time related function as a check when I want to.
We MIGHT be able to retain all of your function with a fraction of the processing if we tune that up right.

Original thread: https://forums.rpgmakerweb.com/threads/fps-dropping-over-time.164820/