Common event "memory leak"

Hello! I was wondering if anyone can figure out why this common event is causing a memory leak (where the game memory usage goes up to 3GB, until the FPS reaches 0, and the game crashes).


I'm basically creating a window popup that shows up on the screen when the player is on a map that is still under construction. I have the following common event:


outofbounds.jpg


I use a Parallel event trigger to turn OutOfBounds switch ON or OFF.


I reckon I caused some kind of loop, but this is the only way to get the popup working "correctly". If I remove the Conditional Branch within the common event switch, the popup still appears on maps where the switch is turned off.


Any help would be appreciated.
If out of bounds is not on, that script will loop over and keep erasing itself.
Eventcommand - Erase Event - Does nothing in a paralell common Event as far as i know. As long its not called by another Event and not on Paralell.


And like the previous Poster mentioned the Eventpage and therefor the Scriptsnippet will continue to run and add up 40 to 60 windows per Seccond.


Thats why your Game slowly dies on FPS.
as said, erase event erased map events (temporarily), it cannot erase or switch off common events.


Which results your CE in creating new windows on and on and on, never releasing the memory allocated to those windows...
Thank you for the replies! Learned something new again 🙂
To add some precision to the answers let us look at the Erase Event code:


Game_Interpreter.prototype.command214 = function() {
if (this.isOnCurrentMap() && this._eventId > 0) {
$gameMap.eraseEvent(this._eventId);
}
return true;
};


The _eventId variable of an interpreter can be set in two ways. One if it a map event. And through a call common event, so let us look at that as well.


// Common Event
Game_Interpreter.prototype.command117 = function() {
var commonEvent = $dataCommonEvents[this._params[0]];
if (commonEvent) {
var eventId = this.isOnCurrentMap() ? this._eventId : 0;
this.setupChild(commonEvent.list, eventId);
}
return true;
};




First let us assume no map changes have occurred.


Conceptually consider calling a common event from a map event as creating an interpreter running under map event as a child. That again may call other common events as children. You may have a long string of interpreters processing common events. If the root of that string, the very first to initiate the call common event is a map event, then all of those children have that same map id.


In that particular case the Erase Event command works on the initiating map event regardless of whether the command is specified on the map event itself, or one of the child interpreters.


The concept of interpreters processing Events rather than events executing is important because it explains the behavior better. When you set a common event to run as a Parallel Process the initiation happens without a map event initiating the call, thus the Erase Event will do nothing. Same is true for Autorun common events. Do note that you can call common events perfectly fine even if their trigger is Autorun and Parallel Process.


Note: Battle events can also call common events.


Note: Self-switch exhibit similar behavior in common events.


*hugs*


 - Zeriab
If the idea is to only have the Common Event run once, it could either be simply called directly, without the Parallel trigger by whatever turns the OutOfBounds Switch On, or end the Event by turning the OutOfBounds Switch to Off (which will affect anything else dependant on that Switch...).


Hope this helps.

Original thread: https://forums.rpgmakerweb.com/threads/common-event-memory-leak.68814/