Hudell's OrangeCustomEvents - Memory leak? with cloned events

The script has been fantastic for the most part, but after a few thousand duplications/deletions, my game always begins to severely lag. It seems like the custom events are still being held somewhere, and eventually clog the system.

I've even created a new project with only my stress testing script and Hudell's script, and it results in the same eventual lag.

OFUf76C.png


And this event is being cloned by this script.



https://www.dropbox.com/s/coka499ob776oc9/Leaking.rar
Well, while it may not be an issue, I have heavy concerns about your complete lack of semicolons in your script. Without them, javascript will guess at where the end of your statement is, and it may guess wrong and you may see bugs because of this.

That said, I have no idea what the delete event code does. Maybe you should link to the script you want help with.
Having a very large events array will cause the game to lag, even if it's filled with nulls. That's why I try to reuse event IDs and keep the array as small as possible.

There might be more problems there though, I'll check your sample code tomorrow.

I use a modified version of OrangeCustomEvents on my own game, but to prevent lag I have multiple event arrays (an array for NPCs, one for farm crops, one for animals and one for regular map events). If you're gonna have thousands of events, you should probably have something similar because the regular event array is iterated on many times per frame.
Yeah, I did already think of trying to minimize the growth of the map's event array. I make it eventually start reusing event IDs (when reasonable). Unfortunately, it seems to run into the same eventual performance issues as when the array growth is left unchecked, though. So it should be related to those events (or something related to them, like self switches being created for them or something?) merely existing.

In both cases, the performance issues begin to occur after around roughly 3500 duplications and "deletions". I'll also attach a link to the stripped-down, fresh project. ~5mb.
Check if that remove event is removing that events sprite as well. Having too many sprites can lower performance even if they don't have an image.
Just checked the code here, the "delete this event" is used to delete saved events so they aren't created anymore on new map changes. For temporary events, it is no different than a regular "erase event" command.

So, yes, there are things to improve there:
  • remove the event from the event list
  • remove the event sprite
Both should have a good impact on perfomance. I'll make those changes tonight.

Original thread: https://forums.rpgmakerweb.com/threads/hudells-orangecustomevents-memory-leak-with-cloned-events.78792/