Forum: Ruby on Rails Memory leak in update from 2.1.2 to 2.2.2

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Ef9ecd30591995af2cf62cde10b26e49?d=identicon&s=25 Wincent Colaiuta (Guest)
on 2009-01-12 11:43
(Received via mailing list)
My last deployment was based on Rails 2.1.2 and would run for months
without restarts and without leaking memory; memory would sit at
around 35 to 40M per Mongrel instance.

On updating to 2.2.2 I'm seeing gradual memory bloat and every few
days it hits its resource limit (130M per Mongrel) and monit does a
restart.

I don't think it's a change in my own code that introduced the leak,
seeing as I made only minimal changes necessary to fix breakage caused
by updating Rails:

$ git diff 3f39f3a..5fc7345 --stat -- app config lib
 app/controllers/application.rb         |   26 +-----
 app/controllers/comments_controller.rb |    4 +-
 app/helpers/application_helper.rb      |   10 +++
 app/helpers/articles_helper.rb         |    6 --
 app/models/user.rb                     |    4 +-
 app/views/articles/edit.html.haml      |    2 +-
 app/views/articles/new.html.haml       |    2 +-
 app/views/articles/show.html.haml      |    2 +-
 app/views/comments/edit.html.haml      |    2 +-
 app/views/issues/_issues.html.haml     |    2 +-
 app/views/search/_article.html.haml    |    2 +-
 app/views/search/_issue.html.haml      |    2 +-
 app/views/search/_post.html.haml       |    2 +-
 app/views/search/_topic.html.haml      |    2 +-
 config/boot.rb                         |    4 +-
 config/deploy.rb                       |    3 +-
 config/environment.rb                  |   14 +---
 config/environments/development.rb     |    2 -
 config/environments/production.rb      |    2 -
 config/environments/test.rb            |    8 +--
 config/initializers/extensions.rb      |   17 ++++
 config/locales/en.yml                  |    5 +
 lib/active_record/acts/classifiable.rb |    2 +-
 lib/active_record/acts/searchable.rb   |    2 +-
 lib/sortable.rb                        |    2 +-
 lib/tasks/rspec.rake                   |  132 ++++++++++++++++++++++++
++++++++
 26 files changed, 194 insertions(+), 67 deletions(-)

So I'm trying to hunt down the source of the leak, but it's kind of
intimidating because it's almost certainly a change in "vendor", which
churned a whole lot from 2.1.2 to 2.2.2:

1313 files changed, 105152 insertions(+), 63806 deletions(-)

Wondering if anyone else has seen memory leaks creep in while moving
from 2.1.2 to 2.2.2?

Cheers,
Wincent
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2009-01-12 11:56
(Received via mailing list)
On 12 Jan 2009, at 10:42, Wincent Colaiuta wrote:

>
> My last deployment was based on Rails 2.1.2 and would run for months
> without restarts and without leaking memory; memory would sit at
> around 35 to 40M per Mongrel instance.
>
> On updating to 2.2.2 I'm seeing gradual memory bloat and every few
> days it hits its resource limit (130M per Mongrel) and monit does a
> restart.
>
I know of two memory leaks in 2.2.2:

http://github.com/rails/rails/commit/9f69ff12d44c4...
http://github.com/rails/rails/commit/5ede4ce188d29...

Fred
Ef9ecd30591995af2cf62cde10b26e49?d=identicon&s=25 Wincent Colaiuta (Guest)
on 2009-01-12 12:19
(Received via mailing list)
On 12 ene, 11:55, Frederick Cheung <frederick.che...@gmail.com> wrote:
>
> I know of two memory leaks in 2.2.2:
>
> 
http://github.com/rails/rails/commit/9f69ff12d44c4......

Thanks a lot, Fred.

I'll try applying both of those fixes before I go any further,
although I suspect they aren't the cause of the bloat I'm seeing (both
of the pieces of code which got patched pre-date 2.1.2 and are
relatively old, one from August 2008 and one from 2006, and I didn't
really see any memory bloat in 2.1.2).

Cheers,
Wincent
4e7a6f370282b5ff91906eff9d200ff8?d=identicon&s=25 avenger (Guest)
on 2009-01-21 12:37
(Received via mailing list)
We had similar problem after upgrading from 2.1.0 to 2.2.2. Rails just
kept accumulating memory. After we applied the buffered logger fix
(http://github.com/rails/rails/commit/
9f69ff12d44c4d1e475fd6efede120ccedba3b3e) we were back normal memory
usage, no leaks.
047e2b3b2770c6051178486d25d82f30?d=identicon&s=25 SurviveStyle5 (Guest)
on 2009-01-21 18:38
(Received via mailing list)
Ran into a similar problem as well. After a frustrating week basically
unpacking all gems, and rebuilding our gem list fixed it (which is a
terrible answer cause i can't rightly say what caused the leak). Best
i can tell there was some issue with different gems that caused a
memory leak and removing and reinstalling them all seemed to resolve
it. Note to self, always check gems into your project
This topic is locked and can not be replied to.