Memory limitations - What should I look out for? What steps can I take?

So after sorting out most of the plugins that will work for my project, I want to know now what the limitations are memory-wise or what are common pitfalls that can sink a project that goes big? I'm aiming simply for a Windows Build, less concerned about mobile.

To start, I'm specifically wondering about Dragonbones image sizes. I've read that 4k (2048x2048) is the largest you should go for individual export sheet sizes for PC and 2k for mobile. But I plan on adding a lot of NPCs with smaller sizes around the 512x512. Every enemy and player character however will be 4k.

What steps can I take or knowledge is available to limit memory being something that sidelines an RMMV project?
I feel it is more a limitation for whatever library you are using for the sheets, in this case Dragonbones. If you are talking about the overall memory limitation for the project, then I guess you can checkout how much RAM you are needing to consume. There are some ways to track this, but a rough way to do it, is to checkout the overall size of all images you are using, like 1GB of images for example.

The way by default that RMMV/MZ does this, is whenever you use a new image on the project, it loads on the RAM on the fly, so the more images the user sees during that gameplay increases the RAM usage for any first seen image. This was done that way because of how extremely few RPG Maker projects goes to a need to actually manage the memory usage, so Ojima who coded the RMMV base code, just made it continuously load on the Cache.

first you need to see how big the memory need for your project will be, if it surpass things like 2GB, 3GB you might start to consider managing loading and unloading the image/sound files you are using.
the main problem isn't so much as any single resource, but how much is on the screen at the same time. Sprites and pictures that are no longer needed get removed from memory after some time.

And unless someone goes for really big screens to fit larger sprites, the biggest memory problems are caused by parallax mapping of big maps. A map picture background needs several thousand times the memory of a tiled map, so even with modern computers you should stay at or below 150x150 tiles for parallax maps (mobiles have problems with 50x50 tile parallaxed maps)
Thank you both for the insight! I'll make sure to note those down.

My concern now remains given what you've mentioned is that in KELYEP_Dragonbones, there's an option to 'Preload Assets' and I set it to ON. It seems to work because it can load 6 characters each that are only 2k with zero delay. I still have to test it with 8 characters at 4K.

It seems by your descriptions that if a game is played long enough, this preloading could cause too much to be stuck in memory. I haven't looked at all into loading/unloading for Dragonbones so I don't know how to do that but I'll save it for another thread once I test if there's a problem.

Thank you very much for these notes, gives me a couple places to start!
yes, but it depends on how the preloader works - depending on how it is used a preloader can be useless or working exactly right or being a permanent memory leak.

to work correctly a preloader has to load the data very shortly before it is needed, and release it directly after the need is past.
If that happens, it is good. Otherwise not so much.
But I don't know how that specific preload function has been programmed.
I don't know if I'm allowed to post code from the script - but the comment tag over the relevant chunk of code should be fine:

//Preload all DragonBones data assigned in 'Preload Assets' parameter
//This is done when this plugin is loaded.

I'm assuming I should be able to see RAM changes in Task Manager so I'll start messing with settings and filesizes and see what differences things make. Thanks again!
If it's working well for you it will probably be okay.
Either way, if you're concerned with performance, consider updating your NW.js as it increases performance by a lot, since the version that RPG Maker uses by default is pretty outdated I think.
Here's a video explaining:

Either way, it's always the best to use small textures on your DragonBones objects. You don't need a 2k image file if your game has a resolution of 1920x1080, as the image will likely never be displayed at full resolution, so you would characters with excessive resolution that players will never get to see because the characters just don't take up that much space on the screen. Take this into account. One way you can do it is open your favorite image editor, create an image with the canvas the same size as the resolution your game will have, and paste the dragon bones texture on that image. If after doing that, the character is looking bigger than it will look on screen, then it has excessive resolution.

Additionally, If you're using Parallax maps, like @Andar mentioned, it can cause the game to lag a lot because Parallax use pretty big image files. So, I actually found a solution for this a few years back, and it allows you to have pretty big parallax maps with little effect on performance.
The way I did it was using Yanfly Doodads. Separate the map into several different chunks, turn each chunk into a doodad, and on playtest use the doodad functionality to place those chunks correctly on the map. The reason this works is because the Doodads are unloaded once they're out of the screen, freeing up some memory. Be careful with using chunks that are too big as they may still disappear on screen. You need to use medium to smaller chunks so they are safely removed without the player seeing it.
Thanks for taking the time again! You do have a misunderstanding about Dragonbones/Spine textures though. The PNG exported from Dragonbones encompass every single art asset for a character's Battler for ALL animations that will be needed in the entire game. 2048x2048 (aka. 4K texture) is very necessary per player character and will be needed for some enemies. Most characters will average about 120px tall that will have frame by frame animation along with puppet animation to save texture space. NPCs wont need more than 512x512.

Also, I've since tested the impact of a 4K texture (2048x2048) in RMMV and it seems that one texture only adds about 300KB to RAM usage. I tested with 8 characters on the screen and there were no slowdowns in loading or playback. Once the battle was over, the RAM usage dropped by roughly the same amount it was raised when the battle started - so it's clear that it loads and unloads properly too.

All in all, an exciting thing to work with!

Additionally, If you're using Parallax maps, like @Andar mentioned, it can cause the game to lag a lot because Parallax use pretty big image files. So, I actually found a solution for this a few years back, and it allows you to have pretty big parallax maps with little effect on performance.
The way I did it was using Yanfly Doodads. Separate the map into several different chunks, turn each chunk into a doodad, and on playtest use the doodad functionality to place those chunks correctly on the map. The reason this works is because the Doodads are unloaded once they're out of the screen, freeing up some memory. Be careful with using chunks that are too big as they may still disappear on screen. You need to use medium to smaller chunks so they are safely removed without the player seeing it.

I hadn't even thought about parallax yet but I'll certainly need these tips for when I get to it. Thanks for taking the time and the helpful tips!
Thanks for taking the time again! You do have a misunderstanding about Dragonbones/Spine textures though. The PNG exported from Dragonbones encompass every single art asset for a character's Battler for ALL animations that will be needed in the entire game. 2048x2048 (aka. 4K texture) is very necessary per player character and will be needed for some enemies. Most characters will average about 120px tall that will have frame by frame animation along with puppet animation to save texture space. NPCs wont need more than 512x512.

Also, I've since tested the impact of a 4K texture (2048x2048) in RMMV and it seems that one texture only adds about 300KB to RAM usage. I tested with 8 characters on the screen and there were no slowdowns in loading or playback. Once the battle was over, the RAM usage dropped by roughly the same amount it was raised when the battle started - so it's clear that it loads and unloads properly too.

All in all, an exciting thing to work with!



I hadn't even thought about parallax yet but I'll certainly need these tips for when I get to it. Thanks for taking the time and the helpful tips!

No problem 🙂
I understand how DragonBones and Spine work, I use them quite a lot! (although not for RPG Maker projects). What I meant was, inside the texture pack, take out the main body or the head or something of the character and compare it to its in-game counterpart.
Like this:
1678754614061.png

(sorry for the low quality edit lol)

In the image above, you can see that the real size of the head of the character is bigger than the size that is displayed in-game, which means that the texture has more resolution than it needs. Make sure that this is not the case with your characters so you're not using up memory unnecessarily.

Even though they appear to not be taking up too much space in RAM (like you said an image is taking up 300k), do remember that it can add up pretty fast if you're not careful, and its always best to do as much optimization as you can, including compressing the png images so they are the smallest they can be. RPG Maker is not a particularly strong engine when it comes to graphics, so it's best to keep these practices when creating a game that will require "out of the ordinary" graphics.
The PNG exported from Dragonbones encompass every single art asset for a character's Battler for ALL animations that will be needed in the entire game. 2048x2048 (aka. 4K texture) is very necessary per player character and will be needed for some enemies.
Even that isn't strictly true if you use some cunning shenanigans. For examples, specific attacking animations can be taken out of a battler and you can use action sequence commands to transform to a different, visually identical battler that has the assets required for that skill, then transform back afterward.
As always when looking into performance optimization, whether they are speed or memory related, make sure to use the included profiler to measure. As a strategy I suggest:
  1. Measure
  2. Optimize
  3. Re-measure
If you don't do measure, you are essentially just doing changes blindly and hoping for the best.

*hugs*
- Zeriab
Sorry for not responding sooner, had a busy few days with deadlines and I'm back to my project today.
Even that isn't strictly true if you use some cunning shenanigans. For examples, specific attacking animations can be taken out of a battler and you can use action sequence commands to transform to a different, visually identical battler that has the assets required for that skill, then transform back afterward.

I would LOVE to know how to do this if you have any insight. This is something I wanted to do but I considered it impossible with the limited commands available within what scripts I've seen for DragonBones. I can think of multiple places where not only would this be useful for normal size characters, but help alleviate spritesheet space while keeping framecount with larger characters too.

----
No problem 🙂
I understand how DragonBones and Spine work, I use them quite a lot! (although not for RPG Maker projects). What I meant was, inside the texture pack, take out the main body or the head or something of the character and compare it to its in-game counterpart.

Thanks Ed! Yeah this is an optimizing that will happen for sure once I know what the upper limits of memory and CPU usage are. I worked on a mobile game using Spine for a couple years. We animators had to jam 4 full-body poses into a 1024x1024 spritesheet. We got to deal with fun times. The scripting, memory, and engine-particular optimizations are the things I never got to learn.

Either way, once I'm more aware of those limitations: I can start calculating a range of what's going to be usable and what's not. If I have something I absolutely want to do in the game but it requires the average size of sprite designs to be smaller to compensate, then I'd like to know everything that can affect it. I'm super curious about Turan's claim above though. That could solve a lot of problems as well.
As always when looking into performance optimization, whether they are speed or memory related, make sure to use the included profiler to measure.

I actually haven't heard the term 'profiler' in regards to game making. A google search tells me that it's useful but a search for RMMV or RPG Maker MV profiler only brings up character profile. Could I bother you for some clarification there or a place to start regarding an included profiler?
Press F12 during test play and go to the Performance tab.

Original thread: https://forums.rpgmakerweb.com/threads/memory-limitations-what-should-i-look-out-for-what-steps-can-i-take.155750/