Ruby on Rails Sunday, May 1, 2016

So I've been struggling a little bit with the different odds and ends of this - particularly because the tooling / resources don't seem to be very comprehensive or well organized. I've been using this guide as a reference https://samsaffron.com/archive/2015/03/31/debugging-memory-leaks-in-ruby - but so far without success.

The Issue:
I have rails server in development taking up to 1.5gb of ram which is far more than should be possible (my development process atm involves repeating server restarts to release the memory every so often). Comparatively on OS X the server is always around ~400mb so my initial thought something is leaking memory and it's system specific (a native extension?).

Memory Consumption:
Here is an example graph of a rails server memory consumption (using ps_mem https://github.com/pixelb/ps_mem), while navigating through the pages of the app and across multiple reloads.

ObjectSpace:
I may be missing something but it doesn't seem to be very helpful so far, the memory-size given by totaling the objects is far short of real memory usage - more so it doesn't seem obvious that the leak is being picked up:

Early dump summary (~600mb it's already quite high but I assume ObjectSpace is also taking up quite a bit):

... ('/home/user/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/binding_of_caller-0.7.2/lib/binding_of_caller/mri2.rb', '4.7 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/2.2.0/webrick/server.rb', '5.1 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/dependencies.rb', '5.1 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/core_ext/marshal.rb', '7.9 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/mime.rb', '50.0 MiB')
(None, '110.3 MiB')

Late Dump Summary (~1300mb):

('/home/user/.rbenv/versions/2.2.4/lib/ruby/2.2.0/webrick/server.rb', '11.2 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/inflector/methods.rb', '12.5 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/2.2.0/webrick/httpresponse.rb', '23.2 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/activesupport-4.2.6/lib/active_support/core_ext/marshal.rb', '33.1 MiB')
('/home/user/.rbenv/versions/2.2.4/lib/ruby/gems/2.2.0/gems/sprockets-3.4.0/lib/sprockets/mime.rb', '50.0 MiB')
(None, '110.3 MiB')


Complete Dump Stats: https://gist.github.com/pik/68976ba49ca8059adf62fdf8de88c357

So far it doesn't look very promising but maybe someone that has dealt with these issues longer can offer some insights. I haven't been able to successfully get ruby to work with valgrind but that would be the next step if this information is insufficient.

Alex

System Details:

ruby
-v: ruby 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
rails
-v: Rails 4.2.6
uname
-a: Linux l-pc 4.5.0-1-ARCH #1 SMP PREEMPT Tue Mar 15 09:41:03 CET 2016 x86_64 GNU/Linux

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/49a784ca-fa23-4590-b35b-c201f40f54ad%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment