peq42_

Yeet
Veteran
Joined
Feb 5, 2016
Messages
527
Reaction score
315
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
34,315
Reaction score
8,754
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
527
Reaction score
315
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
527
Reaction score
315
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
34,315
Reaction score
8,754
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
527
Reaction score
315
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 Profile Posts

I think it's ready - Chapter Selection:
unknown.png
On another more gaming topic, I paid 20 bucks for a visual novel to emotionally destroy me. I may write an entry about that.
1638611395177.png
Reading about metaverses recently. I can totally imagine myself in the future, logging in with VR glasses to a virtual beach villa sitting in a virtual chair, with a virtual laptop facing the sea...coding 16-bit RM.
Mod name: "[Game name] Gameplay Overhaul"
What they actually mean: "Here is a mod that makes the game harder."
I decided to reinstall one of my most favourite game of all times, Gothic 2. Time to get back to Khorinis!

Forum statistics

Threads
117,171
Messages
1,105,130
Members
153,267
Latest member
Christopher626
Top