How can I solve a memory leak in my application?

Hi guys,

I recently moved to Cloud 66 from Heroku, and it seems I have a memory leak in my application. I guess this wasn’t showing on Heroku because of the way they recycle their dynos. I followed your memory issue guide, and Sidekiq looks like the culprit.

Aside from fixing the leak, do you have any short term solution so that I can continue serving content without restarting the workers manually every so often?

You can create a shell command (with the add-in), using this as the command:

for OUTPUT in $(pgrep -f sidekiq); do kill -TERM $OUTPUT; done.

That will run the kill -TERM command on any Sidekiq processes you have running (according to your scheduling). Please make sure to try this, making sure that any existing jobs are actually sent back to Redis before killing the process (according to the Sidekiq documentation).

Please note that this is just a temporary fix - the memory leak will still exist. Have you tried using some form of server monitoring solution to dig deeper?

You must be logged in to answer this question