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-Koser
http://www.marnen.org
[email protected]
-- 
Posted via http://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.

Reply via email to