Very strange - major leak, crashed mongrel

I made what I think is a small change yet the change in my app was
disastrous - cpu spun, memory went out of control, and mongrel crashed
within seconds.

I have a controller which takes a param for submission_id . Submissions
have 1 or more reviews, and reviews each have one image. There may be
more
than one image per submission.

The view (and partial) code does some very intense things, like @
submission.reviews.each | review |
review.image.imageprofile.releases.empty?
, etc. No doubt causes huge joins and queries down the stack.

I built a query for a subset of the reviews belonging to @submission:
@current_reviews = Review.find(:all, :conditions => cond)

The query takes 20 milliseconds. [cond is along the lines of finding
max(id) where [email protected] group by image_id ]

Then when I try to loop thru these in view, replacing @
submission.reviews.each with @current_reviews.each , it leaks like
crazy!
Same code works just fine w/ @submission.reviews.each

The partial that it’s rendering in that loop is huge - 150 lines of
code,
with all kinds of join-inducing references. Why would this behavior be
any
different for a SUBSET ?

Thanks in advance for any insights, things to try, places to look, etc.

Cheers,

Marc

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