When I run this and then watch the memory consumption of my ruby โโprocess in OSX Activity Monitor, the memory grows by about 3 MB / s.
If I delete the transaction, it will reduce the memory consumption by about half, but still the amount of memory continues to grow. I have a problem with my production application where Heroku kills a process due to memory consumption.
Is there any way to do this below so as not to increase memory? If I comment out the .save line, then this is fine, but of course this is not a solution.
ActiveRecord::Base.transaction do 10000000.times do |time| puts "---- #{time} ----" a = Activity.new(:name => "#{time} Activity") a.save!(:validate => false) a = nil end end
I run this with delayed_job .
memory-management ruby ruby-on-rails
Morgz
source share