Identifying a Memory Leak

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
https://lh3.googleusercontent.com/-jj4OTSVJPYA/VyX60Ak4oQI/AAAAAAAAAJM/t8Uq7u2YFxUu5sLvkFCNEy2xoHduZqk0QCLcB/s1600/rails_s_mem.png(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

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