I am sorry but I don't have an answer about the RAM question. However I would like to answer Marnen’s comment. While I agree that letting the DB do the work for mass record processing should be the best and most efficient way to go by reading the OP one cannot assume that is the way things are in this case. The array used by the OP could very well contain tons of different types of objects, used for very different purposes and not necessarily related to each other. Pierre never gave any indication it was one way or the other.
On Jan 30, 8:37 am, Marnen Laibow-Koser <[email protected]> wrote: > PierreW wrote: > > Hi guys, > > > I must be missing something obvious... > > > array_of_stuff = [ contains a lot of fairly small AR objects ] > > > # RAM at 30MB > > > array_of_stuff.each do |foo| > > foo.save > > end > > array_of_stuff = nil > > This is terrible! You should never have a DB query inside a loop. > Instead, generate one query to insert all the records. The > ar-extensions plugin can help with that. > > > > > # RAM at 60+MB > > > The iteration itself takes 30+MB of RAM (I measure with "memory_usage > > from #{pcaller} at l.#{pline}: "+`ps -o rss= -p #{$$}`.to_i.to_s). > > > I don't get it. Why is this using so much memory? > > > Thanks a lot, > > Pierre > > Best, > -- > Marnen Laibow-Koserhttp://www.marnen.org > [email protected] > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

