Is it a memory leak to

I’ve found surprisingly little information on what really causes memory
leaks within Rails. (yes, I know what causes memory leaks in general
– things getting elevated to global scope and not getting freed, etc)
What is lost on me is some of the details.

For example, someone out there discovered that some of his routes were
“ugly” and that caused leaks. I haven’t a clue what an “ugly” route is
or why it causes a memory leak, but I have a more direct question.

Similarly, someone discovered that doing ActiveRecord finds within the
view are a memory leak, too. Is there something about the view scope
that puts it at global scope? I thought it was in the same scope as the
action of the corresponding controller.

Specifically, is there any difference between the two methodologies:

  1. Let the view get the data from ActiveRecord methods
    controller:
    def show
    @person = Person.find(:first)
    end
    view:
    <%= @person.name %> has <%= @person.friends.count %> friends.
    … proceed to list friends …

  2. Get ALL data in the controller:
    controller:
    def show
    @person = Person.find(:first)
    @friends = @person.friends
    end
    view:
    <%= @person.name %> has <%= @friends.size %> friends.
    … proceed to list friends …

    Cheers,
    Jake

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