peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
559
Reaction score
351
First Language
Portuguese(BR)
Primarily Uses
RMMV
I'm using QAudio(https://forums.rpgmakerweb.com/index.php?threads/qplugins-latest-qabs.73023/) on a project on RPG Maker MV(A game which requires constant event spawning using Yanfly's event spawner plugin) but it seems to be causing some issues. Judging by the performance tool on the devtools, that plugin is taking a increasingly long amount of time to run, and an increased long amount of time for some updates to run.

Does anyone know how to fix this issue? I believe the plugin is trying to create a new WebAudio buffer for each and every time an event plays the same song, but idk if that is the case and how to fix it.

EDIT: Just to throw in additional info, the issue happens when theres about 7~8 thousand events, most of which are temporary and get deleted after about half a second of spawning(basically arrows being spawned)
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,946
Reaction score
10,523
First Language
German
Primarily Uses
RMMV
most likely a memory issue.

the problem is that each event needs a bit of RAM assigned to it to work.
Usually that RAM is freed by the so-called garbage collector when it is no longer needed for the event.

But the garbage collector is not perfect and works with a delay - it has to wait a bit before deciding that a bit of RAM can really be cleared and is no longer needed by the event.

And from your description, you spawn events too fast, faster than their RAM can be freed by the garbage collector. And that blocks more and more memory for use.

You either have to recycle events (don't delete the arrows after one flight but re-use them by setting them back to the trap/bow), or reduce the spawn speed to prevent this.
 

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
559
Reaction score
351
First Language
Portuguese(BR)
Primarily Uses
RMMV
most likely a memory issue.

the problem is that each event needs a bit of RAM assigned to it to work.
Usually that RAM is freed by the so-called garbage collector when it is no longer needed for the event.

But the garbage collector is not perfect and works with a delay - it has to wait a bit before deciding that a bit of RAM can really be cleared and is no longer needed by the event.

And from your description, you spawn events too fast, faster than their RAM can be freed by the garbage collector. And that blocks more and more memory for use.

You either have to recycle events (don't delete the arrows after one flight but re-use them by setting them back to the trap/bow), or reduce the spawn speed to prevent this.
it most definitely isn't memory. Even after a few thousand events were spawned, the game won't consume more than maybe 400~500MB of ram. But I imagine it has to do with the amount of checks and whatnot MV does on ALL events, whether or not they've been deleted.

I tried making deleted events become null in the $gameMap._events and $dataMap.events arrays, and it did help(can now get to over 9000 events before dropping frames) but thats still not satisfying. I know I can't simply remove values from an array without it ending up shifting the remaining values left, which would break some stuff in the engine. Any other ways?
 

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
559
Reaction score
351
First Language
Portuguese(BR)
Primarily Uses
RMMV
I've recently tried to use this plugin to solve the issue, as I noticed it sometimes takes up to 50ms to load the sound file, but it doesn't seem to help much. A huge amount of time is still spent on fetching and loading the audio each and every time.

Then I tried preloading with Chau Scene Stabilizer... but now the audio has issues. It won't update the distance properly, and the more times the same audio gets requested, the earlier it gets cut off to run again.
 

Andar

Veteran
Veteran
Joined
Mar 5, 2013
Messages
37,946
Reaction score
10,523
First Language
German
Primarily Uses
RMMV
Then I tried preloading with Chau Scene Stabilizer
I already guessed that it would be a memory issue above - and you tried to solve that by reducing memory further and intenionally creating memory leaks?

Just in case you didn't understand: any preloader is a memory leak by design, because it loads files before they are needed and tells the garbaage collector to not remove that data from RAM as usual.
They can help with reducing lag caused by loading times, at the price of increasing lag by memory shortages.
 

peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
559
Reaction score
351
First Language
Portuguese(BR)
Primarily Uses
RMMV
I already guessed that it would be a memory issue above - and you tried to solve that by reducing memory further and intenionally creating memory leaks?

Just in case you didn't understand: any preloader is a memory leak by design, because it loads files before they are needed and tells the garbaage collector to not remove that data from RAM as usual.
They can help with reducing lag caused by loading times, at the price of increasing lag by memory shortages.
You seem to misunderstand what constitutes a memory leak and what is simply CACHE.

A memory leak is when something is loaded to memory multiple times, or too much of a given data is loaded into memory, accumulating and eventually resulting in a crash or decrease in performance.

CACHE is when you load or process something beforehand, and keep it in the memory because you know it will get used multiple times, and that it is worth it.

Preloading the whole SE folder, which I've cleared and have got rid of the useless m4a files btw, although doesn't work as intended like I said, increased the memory usage by...50MB?100 tops? which considering that my game was using about 400MB at the time is nothing, but it helped a LOT with performance, as now I'm making far less requests to read the disk + decryption. And on top of that, considering that the garbage collector won't automatically unload things from memory, MV's default way of handling memory is FAR, but FAR MORE of a memory leak than preloading like I'm doing, since the file was getting loaded to memory multiple times, and then would have to wait for the GC to decide when its a good time to remove it from there.

so yea, a preloader is not a memory leak. Trying to preload all the game files mindlessly like some people do due to lack of knowledge is.
 

Latest Threads

Latest Posts

Latest Profile Posts

On the "things im remaking" department even i kept getting confused by my status grenades similarity so i decided to redo both of them, now the icons and being thrown animations are very distinctive from each other :kaopride:
1679511126658.gif
1679511135459.gif
I genuinely like the default MZ actor sprites, and the character creator. I think I will draw new headshots for them, but part of me doesn't want to replace the default sprites. But should I? I want to eventually release my game.
Someday, I hope they make a game where 95% of the animation budget went to turning valves and opening door animations, leaving every other animation looking like a CDI zelda cutscene.
programming at 12 years old: "I love how it works!"
programming at 18: "I love that it works."
programming at 25: "I love why it works."
programming at 30: "I love when it works."
programming at 50: "How did this work?"

Forum statistics

Threads
129,766
Messages
1,204,941
Members
170,856
Latest member
CryoHazard
Top