Hi, sorry for the late response.
When you call game_end()
, all of these Clean Up events occur before the game process ends. All of the data used by the game (like your large global data structures) are automatically cleared by the OS when the game process ends. However, if you don't delete these large global data structures on Clean Up, then after calling game_restart()
or room_restart()
can cause the data structures to remain in memory even when the references to them are lost, leading to a memory leak.
Avoid performing too much code in the Clean Up events, especially intensive loops or file access. Of course, you know better than I what is in your Clean Up events.
Have you used the debugger to figure out which Clean Up event is taking up the most time?