2

If I render a partial like so:

= render :partial => "event_news_item", :object => event, :variable => true

And then reference variable in the partial a memory leak is triggered. It seems rails goes into a recursion. I have to then quickly restart my server before memory usage spirals out of control.

Anyone knows why the memory leak is triggered here? Can anyone confirm this on their machine?

If I do

= render :partial => "event_news_item", :object => event

An error is raised correctly when trying to reference variable in the partial.

(The correct way of doing this by the way is

= render :partial => "event_news_item", :object => event, :locals => { :variable => true })

1
  • I can confirm that same behavior occurs randomly in dev mode when I have missing local var/method in helper(s). I think this is because Rails is crap and more specifically because view helpers are entangled method_missing-empowered spaghetti.
    – meandre
    Commented Jan 8, 2013 at 14:12

1 Answer 1

0

I have seen a really bad memory leak in similar environment. I've tracked it to the innocently looking association fetch (comment.author, to be precise), then tried to debug it for some time, and finally gave up and ran on 1.9.3-rc1.

Surprisingly, that fixed this particular memory leak, and, moreover, reduced the unicorns' startup size by 15M (from 85M to 70M; i386).

3
  • The memory savings sound amazing, I might give 1.9.3 a try. However, I'm on Heroku and they use 1.9.2. So it is not really an option for me currently.
    – Nico
    Commented Oct 12, 2011 at 16:12
  • If any C-level leak (i.e. not your fault) manifests itself on your Heroku host, that's not your headache. Matz himself works with them ;) and a bunch of other great programmers too. If you're talking about compatibility, you can just refrain from using the new APIs, which is not very difficult.
    – Catherine
    Commented Oct 13, 2011 at 3:33
  • I have the same problem -- upgrading to 1.9.3 didn't seem to fix it though. Commented Dec 27, 2011 at 20:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.