Skip to content

How to release memory after jobs completed ?

vihuynh edited this page Sep 4, 2018 · 1 revision

Delayed job don't release memory after jobs completed. It's same issue #1015 https://github.com/collectiveidea/delayed_job/issues/1015

  1. Kill worker delayed job if it's eat more memory (LIMIT_MEMORY = 1G) after jobs completed
  class Job
    def perform 
      ....
    end
 
    def after(job)
      if (`ps -o rss= -p #{Process.pid}`.to_i / 1024) > LIMIT_MEMORY
        `kill -15 #{Process.pid}`
      end
    end
  end
  1. Setting monit start worker delayed job. https://github.com/collectiveidea/delayed_job/blob/73bd1b50e719b336b70fcbb8dc4a37ec9b2f6f35/contrib/delayed_job_rails_4_multiple.monitrc

Giangprosite_job

Clone this wiki locally