Optimizing Rails for Memory Usage Part 4: Lazy JSON Generation and Final Thoughts
Code to copy-paste so you can lazily serialize JSON and maybe even stream it to the client, and an argument for why we shouldn’t have to do any of this.
Optimizing Rails for Memory Usage Part 2: Tuning the GC
Changing Ruby’s garbage collection parameters is the least invasive way to optimize your app’s memory usage.