Emacs ate all of my RAM
That's very greedy of Emacs.
You should write a RAM-eating program whose sole purpose is to prevent Emacs from eating more than its fair share of RAM. Your RAM-eating program would be competing against Emacs for RAM, resulting in less RAM usage for Emacs. This is a versatile solution for curbing excessive RAM usage.