I'm building a Rails app (5.0.4, Ruby 2.3.3) that creates a PDF file with Prawn, and sends it to the user, using ActionController's send_data, like this:
# data is a Prawn document
send_data data, type: 'application/pdf', disposition: 'inline', filename: 'document.pdf'
I've noticed on Heroku that the app seems to be using more and more memory with each document that is created and sent. I confirmed this on my local machine with some crude tests. Now, I placed GC.start after the send_data call and the problem seems to be resolved. Memory always goes back to a stable level.
My questions are, is send_data doing something to keep the object around for a long time? And isn't the garbage collector supposed to run "on its own" from time to time? Heroku shows a steady memory increase. Thank you.