0

I created a controller function for build a backup of database or some part of it, but after created the files e sent them, the allocated memory doesn't released.

The memory use report made with rack-mini-profiler gem show that the most part of memory is occupied by ActiveReccord and it doesn't released in the end. The full report is here.

  • Code for create file File.open(zip_data_path, 'r') do |f| send_data f.read, type: 'application/zip', filename:"#{model_name}.zip" end File.delete(zip_data_path) – Rodrigo AIS Feb 14 '17 at 18:50

1 Answers1

0

Here's what I did to reduce memory problems (Not completely resolved).

Write database intensive code in the block written as below.

ActiveRecord::Base.connection_pool.with_connection do
  write your code here...
end

Also you can try running the garbage collector with GC.start in the end of action.

Let me know if this helps