I don't know how doomlazer connects this to a NULL gEgo, though.
I think there were two issues. Robbo fixed the ego problem you spotted, but the showState script was still fragmenting memory. I'm too lazy to read through everything again to check if that's right.
What is it doing and what is best practice here? Should I be adding other scripts here like my regions path script maybe? Does this free up heap space as I'm already skating on thin ice with that.
Essentially you've got scripts that always live in memory like main, game, etc.. Then you have scripts that are loaded when a room script uses them. On room change, everything that was loaded for that room needs to get disposed to keep memory unfragmented. Some stuff, like actor instances, get cleaned up automatically because the lsl3 (or template game) code was already written to do so.
When I looked at Sluicebox's lsl3 decompile, I couldn't find script 797, so I assumed you had imported this yourself, copied from the lsl3 source code. The game isn't going to automatically know to dispose new scripts you add. Since you are calling this new script from a room script, you need to be responsible for cleaning it up. You're using it across more than one room, so disposing in startRoom is an effective way to ensure it's cleaned up every room change. DisposeScript safely ignores any of the args that weren't loaded in a given room.
I'm guessing you're adding (use SHOW_STATE) to the top of each room script? Another way to call showState would be:
;(ShowState self newState 1 2)
((ScriptId SHOW_STATE 1) self newState 1 2)
(DisposeScript SHOW_STATE)
This loads script 979 then calls method index 1 (ShowState has been assigned 1 in the script's public methods). Once the method returns, it's cleaned up by the DisposeScript call. No need to add (use SHOW_STATE) to the room script and script 979 isn't taking up heap the entire time the player is in the room.
It gives you a bit more control over the heap, but in the case of SHOW_STATE it's probably better to leave it as you have it now. You need enough heap for the room + 979 when ScriptId gets called anyway.
I'm not clear what 'regions path' is, but regions are generally going to be disposed by newRoom automatically.
Here's some great info on heap fragmentation:
https://sciprogramming.com/tutorial.php?entry=5402