Introduce support for being able to dump Rails heap after script/bench.rb runs

References https://github.com/discourse/discourse/pull/3020 using discourse as a sandbox for a GC and heap analysis tool we're working on. I need a heap snapshot at the end of a bench run for testing - please accept if useful upstream too.