Find_each leaks (a lot)?

Hi guys,

I need to load a big amount of records from a table (around 20000). So
I am using find_each. In the RDoc it says:
“When processing large numbers of records, it‘s often a good idea to
do so in batches to prevent memory ballooning.”

I am not sure I get it though, indeed:

1- If I do:

Foo.find_each(:batch_size => 1000) do |lfoo|

RAM use go from 33MB before to 92MB after.

2- Now if I do:

temp = Foo.find(:all, :limit => 1000)

RAM use go from 33MB before to 35MB after.

How come does find_each use so much memory? I must be missing
something obvious?

I am on Rails 2.3.2.

Thanks a lot,

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs