Graphical Object Global Reference VX(game.exe crash debugger)by MithranNOTICE: This is the VX version of the script. For the VX ACE Version go HEREIntroduction Getting seemingly random and yet occasionally predictable Game.exe crashes? "Game.exe has encountered a problem and needs to close" This is one of the most frustrating errors to deal with in RPG Maker VX as it seems to come and go at random, only affecting certain people or setups, and the actual cause of the error is hidden to you. If your project is getting persistent Game.exe crashes or even occasional Game.exe crashes across more than one system, this may be worth a read. Hell, even if its not, it might still be worth a look. This script addresses one specific issue that can cause an unhandled exception leading to an eventual Game.exe crash. Your mileage may vary. Spoiler The cause of a given Game.exe crash could be any number of things - anything that doesn't create throw an error in Ruby, but causes an unhandled exception in one of the 'hidden' classes. After extensive testing, I was finally able to recreate the circumstances leading up to one such exception that, if left unhandled, could lead to Game.exe crash. 1. A "GO" - Graphical Object (Sprite, Window, Plane, or Tilemap) is created 2. The Graphical Object is assigned a Viewport 3. The Viewport is disposed, but the sprite is not 4. The Graphical Object is claimed by GC (garbage disposal)* * - Newly Discovered: attempting to dispose a sprite that has a disposed viewport will occasionally also crash. (v 1.1) Note that this particuar crash only seems to occur if screen draws have taken place (any of the Graphics methods) between the time the viewport is disposed and the sprite disposal is attempted. Due to the way GC is implemented, you are unlikely to see an immediate effect when the situation comes up. It could be several scene changes down the line before the crash finally happens. To make matters worse, following the exact same course of action will yield completely different results, making it seem as though the crashes are random. In addition, there is yet another circumstance which I have still been unable to pinpoint, but I suspect has something to do with the order in which assets associated with the Graphical Object are claimed by the GC, or the amount of screen rewdraws that have taken place, that allows the GO to be cliamed without causing an exception and thus making it even harder to find. In essence: you could be suffering from an unstable game and not even know it. So that is where this little script comes in. This does the following: 1. Creates a global variable backreference to every Graphical Object created. This prevents them from being marked by the GC so long as the reference exists, circumventing the final condition to cause this version of the crash. 2. Removes reference to the Graphical Object once it has been disposed. This reallows the object to be marked by GC for disposal (once all other references are removed). Since the GO is disposed, condition 3 is no longer met and the object is deemed 'safe'. 3. Report on potential issues to the user. This allows the user (given limited scripting knowledge) to identify potential errors and fix them outright. 4. Prevents further Game.exe crashes caused by this specific issue. Includes a 'lazy' fix that cleans up offending Graphical Objects when the scene changes.* * v 1.1 'Lazy' fix has been superceeded to prevent crashes caused by disposal of these errant sprites. Lazy fix only works if debug criticial disposal has been disabled. Version History: v 1.1 Discovered a new condition for a Game.exe crash. Updated script to trap and log this error also. v 1.01-1.05 Minor bugfixes, improved logging, added consideration for Plane objects viewport method error v 1.0 Initial Release Features - Identifies and reports a prevalent, and generally very easy to fix, cause of Game.exe crashes. - Creates a global reference to every graphical object created until it is disposed to prevent the error from causing this specific Game.exe crash while it is running Script http://pastebin.com/raw.php?i=rW9qkbxT How to Use Install on its own script page in the materials section of the script editor above main and below default scripts. If using a script that creates sprites at startup (eg. Woratana Simple Mouse System), this script must come after it on the list. FAQ Q: Game.exe crashes for me constantly and this didn't help! A: As explained, this only prevents Game.exe crashes caused by the specific set of circumstances outlined. Crashes caused by memory faults or other errors may still remain, but if there is an in-game reason for it (read: crashes happen after x set of actions are taken with a fair degree of consistency, or across several computers) feel free to leave a post here. Q: I'm using a cracked version and.. A: Support will not be given for non-official versions. Using a cracked version is also against the forum rules, among other things, and will get you banned. Q: I found another way to force a Game.exe crash in a seemingly stable game. A: I'd love to hear about it. Drop a post with the details. Credit and Thanks - Mithran Author's Notes May be distributed with a link to these forums, original unedited script, and with credit. May be used in any project, so long as the credit in the script remains intact (individual credit in the project as a whole is not required). Bug Reporting If you encounter an error, please provide the complete error code as well as a short description on how to reproduce.