Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory usage keeps increasing #1047

Closed
robinsingh-bw opened this issue Aug 14, 2016 · 57 comments
Closed

Memory usage keeps increasing #1047

robinsingh-bw opened this issue Aug 14, 2016 · 57 comments

Comments

@robinsingh-bw
Copy link

Hi,

I have been tracking a memory leak in my app and it seems the leak disappears if I switch to a different webserver, I have tried webrick/unicorn/passenger and none of them have the leak. I also tried running puma with a single process and 1 thread, the leak was still there. I moved puma to a dummy project in an attempt to isolate the problem. I have found that the leak only appears when running on heroku, I cant replicate it on my development server.

Steps to reproduce:
rails new pumaleak
swap out the gemfile with the one provided
bundle
git init
git add -A
git commit -am 'initial commit'
heroku create
heroku labs:enable log-runtime-metrics
git push heroku master
heroku logs -t

Heres my gemfile (no other changes to the default rails app):

source 'https://rubygems.org'
ruby '2.3.1'

gem 'rails', '4.2.6'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'puma'

group :development do
  gem 'sqlite3'
end

group :production do
  gem 'pg'
    gem 'rails_12factor'
end

Heroku logs (notice the ram going up over time, I ran it overnight and the ram kept going up ~10mb over 24 hours, running a GC does not revert it):

2016-08-14T14:19:25.464702+00:00 heroku[web.1]: Process exited with status 0
2016-08-14T14:19:28.147456+00:00 app[web.1]: => Booting Puma
2016-08-14T14:19:28.147483+00:00 app[web.1]: => Rails 4.2.6 application starting in production on http://0.0.0.0:10950
2016-08-14T14:19:28.147484+00:00 app[web.1]: => Run `rails server -h` for more startup options
2016-08-14T14:19:28.147485+00:00 app[web.1]: => Ctrl-C to shutdown server
2016-08-14T14:19:29.389622+00:00 app[web.1]: Puma starting in single mode...
2016-08-14T14:19:29.389637+00:00 app[web.1]: * Version 3.6.0 (ruby 2.3.1-p112), codename: Sleepy Sunday Serenity
2016-08-14T14:19:29.389638+00:00 app[web.1]: * Min threads: 0, max threads: 16
2016-08-14T14:19:29.389639+00:00 app[web.1]: * Environment: production
2016-08-14T14:19:29.389776+00:00 app[web.1]: * Listening on tcp://0.0.0.0:10950
2016-08-14T14:19:29.390027+00:00 app[web.1]: Use Ctrl-C to stop
2016-08-14T14:19:29.875747+00:00 heroku[web.1]: State changed from starting to up
2016-08-14T14:19:30.623251+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.27MB sample#memory_rss=62.26MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=16494pages sample#memory_pgpgout=554pages sample#memory_quota=512.00MB
2016-08-14T14:19:51.176509+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.27MB sample#memory_rss=62.26MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=17535pages sample#memory_pgpgout=1595pages sample#memory_quota=512.00MB
2016-08-14T14:20:11.162244+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:20:11.162358+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.29MB sample#memory_rss=62.28MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=18818pages sample#memory_pgpgout=2873pages sample#memory_quota=512.00MB
2016-08-14T14:20:30.810606+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:20:30.810697+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.29MB sample#memory_rss=62.28MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=18818pages sample#memory_pgpgout=2873pages sample#memory_quota=512.00MB
2016-08-14T14:20:50.617791+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:20:50.617791+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.29MB sample#memory_rss=62.28MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=18818pages sample#memory_pgpgout=2873pages sample#memory_quota=512.00MB
2016-08-14T14:21:11.031097+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:21:11.031348+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.29MB sample#memory_rss=62.28MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=18985pages sample#memory_pgpgout=3040pages sample#memory_quota=512.00MB
2016-08-14T14:21:31.087996+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:21:31.088112+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.29MB sample#memory_rss=62.28MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19035pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:21:50.859317+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:21:50.859531+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.29MB sample#memory_rss=62.28MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19035pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:22:11.131602+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:22:11.131728+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.30MB sample#memory_rss=62.30MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19039pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:22:31.185586+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:22:31.185726+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.30MB sample#memory_rss=62.30MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19039pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:22:50.973286+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:22:50.973501+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.30MB sample#memory_rss=62.30MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19039pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:23:11.097588+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:23:11.097702+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.30MB sample#memory_rss=62.30MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19039pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:23:31.191812+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:23:31.191972+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.30MB sample#memory_rss=62.30MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19039pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:23:51.225113+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00
2016-08-14T14:23:51.225113+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.30MB sample#memory_rss=62.30MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19039pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:24:10.966237+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:24:10.966350+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.32MB sample#memory_rss=62.31MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19043pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:24:30.974942+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:24:30.975052+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.32MB sample#memory_rss=62.31MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19043pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:24:50.441331+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:24:50.441452+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.32MB sample#memory_rss=62.31MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19043pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:25:11.266474+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:25:11.266647+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.32MB sample#memory_rss=62.31MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19043pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:25:30.984663+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:25:30.984663+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.32MB sample#memory_rss=62.31MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19043pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:25:50.744222+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:25:50.744340+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.32MB sample#memory_rss=62.31MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19043pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:26:11.096277+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:26:11.096375+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.33MB sample#memory_rss=62.33MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19047pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:26:30.759977+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:26:30.760093+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.33MB sample#memory_rss=62.33MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19047pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:26:50.769981+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:26:50.770136+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.33MB sample#memory_rss=62.33MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19047pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:27:10.797757+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:27:10.797986+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.33MB sample#memory_rss=62.33MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19047pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:27:31.067370+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:27:31.067567+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.33MB sample#memory_rss=62.33MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19047pages sample#memory_pgpgout=3090pages sample#memory_quota=512.00MB
2016-08-14T14:27:50.629526+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:27:50.629601+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.33MB sample#memory_rss=62.33MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19049pages sample#memory_pgpgout=3092pages sample#memory_quota=512.00MB
2016-08-14T14:28:11.500555+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:28:11.500811+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.35MB sample#memory_rss=62.34MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19053pages sample#memory_pgpgout=3092pages sample#memory_quota=512.00MB
2016-08-14T14:28:31.051358+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:28:31.051528+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.35MB sample#memory_rss=62.34MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19053pages sample#memory_pgpgout=3092pages sample#memory_quota=512.00MB
2016-08-14T14:28:50.694035+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:28:50.694161+00:00 heroku[web.1]: source=web.1 dyno=heroku.55116999.d72a0fcf-23c8-4919-b268-d0656f7b4d6d sample#memory_total=62.35MB sample#memory_rss=62.34MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=19053pages sample#memory_pgpgout=3092pages sample#memory_quota=512.00MB
@robinsingh-bw
Copy link
Author

The leak in my app is much more evident:

2016-08-14T14:28:43.284567+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=168.46MB sample#memory_rss=168.43MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=47343pages sample#memory_pgpgout=4218pages sample#memory_quota=512.00MB
2016-08-14T14:29:03.445347+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=168.90MB sample#memory_rss=168.88MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72567pages sample#memory_pgpgout=29328pages sample#memory_quota=512.00MB
2016-08-14T14:29:24.378890+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:29:24.378968+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=168.95MB sample#memory_rss=168.92MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72579pages sample#memory_pgpgout=29328pages sample#memory_quota=512.00MB
2016-08-14T14:29:45.509970+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:29:45.510245+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=169.09MB sample#memory_rss=169.07MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72616pages sample#memory_pgpgout=29328pages sample#memory_quota=512.00MB
2016-08-14T14:30:06.424100+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:30:06.424205+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=169.28MB sample#memory_rss=169.25MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72685pages sample#memory_pgpgout=29349pages sample#memory_quota=512.00MB
2016-08-14T14:30:27.572912+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:30:27.573007+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=169.55MB sample#memory_rss=169.52MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72753pages sample#memory_pgpgout=29349pages sample#memory_quota=512.00MB
2016-08-14T14:30:48.515228+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:30:48.515513+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=169.57MB sample#memory_rss=169.54MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72758pages sample#memory_pgpgout=29349pages sample#memory_quota=512.00MB
2016-08-14T14:31:09.437338+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:31:09.437410+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=169.61MB sample#memory_rss=169.58MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72773pages sample#memory_pgpgout=29354pages sample#memory_quota=512.00MB
2016-08-14T14:31:30.519127+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:31:30.519460+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=169.88MB sample#memory_rss=169.86MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72844pages sample#memory_pgpgout=29354pages sample#memory_quota=512.00MB
2016-08-14T14:31:51.502919+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:31:51.503097+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=169.92MB sample#memory_rss=169.89MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72854pages sample#memory_pgpgout=29354pages sample#memory_quota=512.00MB
2016-08-14T14:32:12.788326+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:32:12.788326+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=170.23MB sample#memory_rss=170.21MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72934pages sample#memory_pgpgout=29354pages sample#memory_quota=512.00MB
2016-08-14T14:32:33.741972+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:32:33.742083+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=170.31MB sample#memory_rss=170.29MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=72967pages sample#memory_pgpgout=29367pages sample#memory_quota=512.00MB
2016-08-14T14:32:54.631010+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:32:54.631073+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=170.54MB sample#memory_rss=170.52MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=73026pages sample#memory_pgpgout=29367pages sample#memory_quota=512.00MB
2016-08-14T14:33:15.433935+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00
2016-08-14T14:33:15.434042+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=170.62MB sample#memory_rss=170.59MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=73045pages sample#memory_pgpgout=29367pages sample#memory_quota=512.00MB
2016-08-14T14:33:36.461219+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:33:36.461411+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=170.82MB sample#memory_rss=170.79MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=73097pages sample#memory_pgpgout=29367pages sample#memory_quota=512.00MB
2016-08-14T14:33:57.767663+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:33:57.767801+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=171.04MB sample#memory_rss=171.01MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=73230pages sample#memory_pgpgout=29445pages sample#memory_quota=512.00MB
2016-08-14T14:34:18.833845+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:34:18.833939+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=171.11MB sample#memory_rss=171.08MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=73248pages sample#memory_pgpgout=29445pages sample#memory_quota=512.00MB
2016-08-14T14:34:39.339373+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:34:39.339452+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=171.39MB sample#memory_rss=171.36MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=84232pages sample#memory_pgpgout=40357pages sample#memory_quota=512.00MB
2016-08-14T14:35:00.500665+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:35:00.500768+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=171.45MB sample#memory_rss=171.42MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=84248pages sample#memory_pgpgout=40357pages sample#memory_quota=512.00MB
2016-08-14T14:35:21.464147+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:35:21.464217+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=171.64MB sample#memory_rss=171.61MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=84297pages sample#memory_pgpgout=40357pages sample#memory_quota=512.00MB
2016-08-14T14:35:42.276521+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:35:42.276521+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=171.70MB sample#memory_rss=171.67MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=91876pages sample#memory_pgpgout=47922pages sample#memory_quota=512.00MB
2016-08-14T14:36:03.521556+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:36:03.521663+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=172.00MB sample#memory_rss=171.97MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=91954pages sample#memory_pgpgout=47922pages sample#memory_quota=512.00MB
2016-08-14T14:36:24.454603+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:36:24.454736+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=172.13MB sample#memory_rss=172.10MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=91987pages sample#memory_pgpgout=47922pages sample#memory_quota=512.00MB
2016-08-14T14:36:45.613863+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:36:45.613863+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=172.20MB sample#memory_rss=172.17MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=92005pages sample#memory_pgpgout=47922pages sample#memory_quota=512.00MB
2016-08-14T14:37:06.528348+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:37:06.528460+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=172.48MB sample#memory_rss=172.45MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=105845pages sample#memory_pgpgout=61690pages sample#memory_quota=512.00MB
2016-08-14T14:37:27.785310+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:37:27.785464+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=172.55MB sample#memory_rss=172.52MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111444pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:37:48.725610+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=172.73MB sample#memory_rss=172.70MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111491pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:37:48.725385+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:38:10.470882+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:38:10.471080+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=172.82MB sample#memory_rss=172.79MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111513pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:38:30.519422+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:38:30.519528+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=173.08MB sample#memory_rss=173.05MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111581pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:38:51.339172+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:38:51.339305+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=173.13MB sample#memory_rss=173.10MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111593pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:39:12.503860+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=173.38MB sample#memory_rss=173.35MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111657pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:39:12.503755+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:39:33.575267+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:39:33.575371+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=173.74MB sample#memory_rss=173.71MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111749pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:39:54.499242+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:39:54.499318+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=173.77MB sample#memory_rss=173.74MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111756pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:40:15.518385+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:40:15.518510+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=173.82MB sample#memory_rss=173.79MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111770pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:40:36.496464+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:40:36.496749+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=174.07MB sample#memory_rss=174.05MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111835pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:40:57.371656+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:40:57.371721+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=174.14MB sample#memory_rss=174.11MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111852pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:41:18.639802+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:41:18.639934+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=174.36MB sample#memory_rss=174.34MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111909pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:41:39.485795+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:41:39.485932+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=174.44MB sample#memory_rss=174.41MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111929pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:42:00.524753+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:42:00.524907+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=174.59MB sample#memory_rss=174.57MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=111968pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:42:21.208558+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:42:21.208612+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=174.83MB sample#memory_rss=174.80MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=112028pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:42:42.424861+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:42:42.424961+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=174.89MB sample#memory_rss=174.87MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=112045pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:43:03.808435+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:43:03.808739+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=175.09MB sample#memory_rss=175.07MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=112096pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:43:24.567501+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:43:24.567671+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=175.14MB sample#memory_rss=175.11MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=112107pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:43:45.379209+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00
2016-08-14T14:43:45.379318+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=175.27MB sample#memory_rss=175.24MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=112140pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB
2016-08-14T14:44:06.228378+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#load_avg_1m=0.00 sample#load_avg_5m=0.00 sample#load_avg_15m=0.00
2016-08-14T14:44:06.228546+00:00 heroku[web.1]: source=web.1 dyno=heroku.50110634.08176180-a5e9-4073-9941-93fe83ce6dcf sample#memory_total=175.57MB sample#memory_rss=175.55MB sample#memory_cache=0.03MB sample#memory_swap=0.00MB sample#memory_pgpgin=112219pages sample#memory_pgpgout=67272pages sample#memory_quota=512.00MB

@evanphx
Copy link
Member

evanphx commented Aug 21, 2016

Thank you for the details, i'll go about reproducing and getting some data shortly.

@frodsan
Copy link
Contributor

frodsan commented Aug 24, 2016

I'm seeing the same report in my logs. I'm going to try different versions of puma.

@berardpb
Copy link

I'm experiencing the same issue.

@dcorlett
Copy link

We have the same "ever increasing memory" issue with puma on Heroku, and have never been able to resolve it (since moving to puma 6 months ago). I've spent quite a bit of time with derailed in my local dev environment, but have never been able to reproduce what we're seeing on Heroku. The "solution" mentioned in various other threads is to run the pumaworkerkiller gem, but this is a hack and it would certainly be nice to put this issue to rest once and for all! @robinsingh-bw thanks for reproducing it in isolation with a minimalist Heroku app.

@evanphx
Copy link
Member

evanphx commented Aug 29, 2016

@schneems I'm starting to wonder if it's something about the malloc that heroku is using. Could you tell us a little about how the heroku ruby's are compiled?

@evanphx
Copy link
Member

evanphx commented Aug 29, 2016

@robinsingh-bw Is that app receiving any traffic?

@schneems
Copy link
Contributor

We use a ubuntu image, cedar 14 uses ubuntu 14. I think it's available via docker hub but not really kept up to date https://hub.docker.com/u/heroku/. We don't do anything special with malloc that I know of. @hone might be able to say more.

@evanphx
Copy link
Member

evanphx commented Aug 29, 2016

No jemalloc or anything?

@schneems
Copy link
Contributor

@evanphx
Copy link
Member

evanphx commented Aug 29, 2016

Hm. ok.

@robinsingh-bw
Copy link
Author

robinsingh-bw commented Aug 29, 2016

@evanphx The test app on heroku does not receive any traffic at all, the usage just starts going up as soon as the server starts.

Also, the logs I pasted are in sequence, I did not cut anything out. It looks like some background thread might be leaking. The leak is much larger in my app where the memory usage is going up by megabytes (not KB like with the test app) even though I am making no web requests.

@evanphx
Copy link
Member

evanphx commented Aug 29, 2016

@robinsingh-bw I'm confused why it doesn't shutdown due to being idle then...

@asia653
Copy link

asia653 commented Aug 29, 2016

Can you chart the data for a longer period of time? Your application might just have a high resident memory usage and it hasn't 'capped out'

@robinsingh-bw
Copy link
Author

robinsingh-bw commented Aug 29, 2016

@evanphx Its a hobby instance not a free one. It restarts every 24 hours.

@evanphx
Copy link
Member

evanphx commented Aug 29, 2016

@robinsingh-bw Ah ok. I'm adding a curl every few minutes to keep the free one up and testing now. RSS creep like this is likely the behavior of malloc(2) rather than something inside ruby/puma based on my experience.

In your regular app, do you see memory grow and grow until the instance hits the ceiling?

@robinsingh-bw
Copy link
Author

@edwardzyc The test app just keeps going up until the instance is restarted, my app starts getting R14 out of memory.

@evanphx
Copy link
Member

evanphx commented Aug 29, 2016

@robinsingh-bw My concern is that this is actually malloc fragmentation rather than a leak in puma.

@robinsingh-bw
Copy link
Author

robinsingh-bw commented Aug 30, 2016

I have taken some screenshots of the memory usage graph from heroku.

At the beginning usage looks like this: http://imgur.com/brKLOo4
First log line:
2016-08-29T23:24:26.780030+00:00 heroku web.1 - - source=web.1 dyno=heroku.55116999.055abfbe-7dc5-4b65-88c4-27f5de6383c5 sample#memory_total=62.27MB sample#memory_rss=62.27MB sample#memory_cache=0.00MB sample#memory_swap=0.00MB sample#memory_pgpgin=16159pages sample#memory_pgpgout=217pages sample#memory_quota=512.00MB

At the end the usage looks like this: http://imgur.com/M8KMHyQ
Last log line:
2016-08-30T11:58:25.453427+00:00 heroku web.1 - - source=web.1 dyno=heroku.55116999.055abfbe-7dc5-4b65-88c4-27f5de6383c5 sample#memory_total=68.87MB sample#memory_rss=66.10MB sample#memory_cache=0.63MB sample#memory_swap=2.14MB sample#memory_pgpgin=20634pages sample#memory_pgpgout=18882pages sample#memory_quota=512.00MB

During the same time my production app consumed almost 50mb (although it appears the rss actually went down by 23mb and swap memory went up by 77mb, not sure if thats relevant). Heres the start and end screenshots for it:
http://imgur.com/j0ekx6j
http://imgur.com/1mRebPz

Note that I did not make any web requests during the time to either of the apps.

@jrafanie
Copy link

Sorry, I can't tell if MALLOC_ARENA_MAX was configured here. It's worthwhile checking even though it looks like puma has only 16 threads. Here's more info.

@evanphx
Copy link
Member

evanphx commented Sep 5, 2016

So I've been running a dyno for the last week and there memory has not grown out of control. It's a sawtooth pattern but I never saw it go above 65MB and generally started around 62MB.

@robinsingh-bw On the smaller one, did you see the memory actually grow out of control? Or was it just the other app?

@robinsingh-bw
Copy link
Author

@evanphx It just happens with the other app, smaller one just goes up ~10mb before heroku restarts the dyno.

@evanphx
Copy link
Member

evanphx commented Sep 5, 2016

Why does heroku restart it?
On Mon, Sep 5, 2016 at 12:49 PM robinsingh-bw notifications@github.com
wrote:

@evanphx https://github.com/evanphx It just happens with the other app,
smaller one just goes up ~10mb before heroku restarts the dyno.


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#1047 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAAByeIY1o81UFdNzxxkfKf6HsR0SzPks5qnHJfgaJpZM4Jj6T9
.

@robinsingh-bw
Copy link
Author

Its the 24 hour rolling restart.

@evanphx
Copy link
Member

evanphx commented Sep 5, 2016

Ah, gotcha. On the app, how quickly does the memory ramp up and what size
dyno are you using?
On Mon, Sep 5, 2016 at 12:51 PM robinsingh-bw notifications@github.com
wrote:

Its the 24 hour rolling restart.


You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub
#1047 (comment), or mute
the thread
https://github.com/notifications/unsubscribe-auth/AAAAB05h09yndeYCYgVe1Gfq4BZjjxEgks5qnHLdgaJpZM4Jj6T9
.

@robinsingh-bw
Copy link
Author

I posted some screenshots of it earlier: #1047 (comment)

@evanphx
Copy link
Member

evanphx commented Sep 5, 2016

That kind of growth doesn't seem outside the norm how malloc(2) will hold on or release memory back to the system.

The long and short of it is that I've audit the puma codebase many times now looking for memory leaks using all kinds of tools. So at this stage I'll have to say that this is MRI's interaction with malloc(2) and how malloc(2) is able to release memory back to the system. Because MRI uses malloc(2) to allocate the memory for most data structures, it's susceptible to fragmentation.

@robinsingh-bw
Copy link
Author

I see, thanks for looking into this. I just find it peculiar that the memory usage is spiking in my app even though there are 0 web requests, it only happens on heroku not on my local server. Anyway i resorted to a 1gb heroku instance (perhaps that's their intent?).

@evanphx
Copy link
Member

evanphx commented Sep 5, 2016

@robinsingh-bw No problem on this end. I'm going to continue to investigate because I don't like saying "sorry not, my problem." Did you try the malloc arena setting recommended above?

@lephyrius
Copy link

I dunno if it helps. But I noticed this as well.
I followed these instructions but I used this Gemfile instead:

source 'https://rubygems.org'
ruby '2.3.1', engine: 'jruby', engine_version: '9.1.5.0'

gem 'rails', '4.2.7.1'
gem 'sass-rails', '~> 5.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.1.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc

gem 'puma'

gem 'activerecord-jdbcpostgresql-adapter', require: false

group :production do
    gem 'rails_12factor'
end

Here is the log:

2016-10-11T07:44:29.769553+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.54MB sample#memory_rss=360.48MB sample#memory_cache=0.20MB sample#memory_swap=0.86MB sample#memory_pgpgin=193872pages sample#memory_pgpgout=106650pages sample#memory_quota=512.00MB
2016-10-11T07:44:49.824181+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.17 sample#load_avg_15m=1.37
2016-10-11T07:44:49.824257+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.54MB sample#memory_rss=360.48MB sample#memory_cache=0.20MB sample#memory_swap=0.86MB sample#memory_pgpgin=194870pages sample#memory_pgpgout=107648pages sample#memory_quota=512.00MB
2016-10-11T07:45:10.628343+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.16 sample#load_avg_15m=1.34
2016-10-11T07:45:10.628414+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.54MB sample#memory_rss=360.48MB sample#memory_cache=0.20MB sample#memory_swap=0.86MB sample#memory_pgpgin=195503pages sample#memory_pgpgout=108281pages sample#memory_quota=512.00MB
2016-10-11T07:45:30.150945+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.15 sample#load_avg_15m=1.31
2016-10-11T07:45:30.151103+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.54MB sample#memory_rss=360.48MB sample#memory_cache=0.20MB sample#memory_swap=0.86MB sample#memory_pgpgin=195651pages sample#memory_pgpgout=108429pages sample#memory_quota=512.00MB
2016-10-11T07:45:49.948651+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.14 sample#load_avg_15m=1.28
2016-10-11T07:45:49.948651+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.77MB sample#memory_rss=360.48MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=195753pages sample#memory_pgpgout=108473pages sample#memory_quota=512.00MB
2016-10-11T07:46:08.592752+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.13 sample#load_avg_15m=1.25
2016-10-11T07:46:08.592846+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.77MB sample#memory_rss=360.48MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=195753pages sample#memory_pgpgout=108473pages sample#memory_quota=512.00MB
2016-10-11T07:46:29.074225+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.12 sample#load_avg_15m=1.23
2016-10-11T07:46:29.074225+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.78MB sample#memory_rss=360.49MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=195755pages sample#memory_pgpgout=108473pages sample#memory_quota=512.00MB
2016-10-11T07:46:49.659795+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.29 sample#load_avg_5m=0.18 sample#load_avg_15m=1.22
2016-10-11T07:46:49.659909+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.78MB sample#memory_rss=360.49MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=196881pages sample#memory_pgpgout=109599pages sample#memory_quota=512.00MB
2016-10-11T07:47:09.189253+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.21 sample#load_avg_5m=0.17 sample#load_avg_15m=1.20
2016-10-11T07:47:09.189253+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.79MB sample#memory_rss=360.49MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=196882pages sample#memory_pgpgout=109599pages sample#memory_quota=512.00MB
2016-10-11T07:47:29.624636+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.15 sample#load_avg_5m=0.16 sample#load_avg_15m=1.17
2016-10-11T07:47:29.624770+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.79MB sample#memory_rss=360.50MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=197991pages sample#memory_pgpgout=110707pages sample#memory_quota=512.00MB
2016-10-11T07:47:50.756658+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.10 sample#load_avg_5m=0.15 sample#load_avg_15m=1.14
2016-10-11T07:47:50.756745+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.81MB sample#memory_rss=360.52MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=198014pages sample#memory_pgpgout=110725pages sample#memory_quota=512.00MB
2016-10-11T07:48:09.975309+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.08 sample#load_avg_5m=0.14 sample#load_avg_15m=1.12
2016-10-11T07:48:09.975359+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.95MB sample#memory_rss=360.66MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=198051pages sample#memory_pgpgout=110726pages sample#memory_quota=512.00MB
2016-10-11T07:48:28.884269+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.06 sample#load_avg_5m=0.13 sample#load_avg_15m=1.09
2016-10-11T07:48:28.884342+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.95MB sample#memory_rss=360.66MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=198051pages sample#memory_pgpgout=110726pages sample#memory_quota=512.00MB
2016-10-11T07:48:49.406683+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.04 sample#load_avg_5m=0.12 sample#load_avg_15m=1.07
2016-10-11T07:48:49.406808+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.95MB sample#memory_rss=360.66MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=198051pages sample#memory_pgpgout=110726pages sample#memory_quota=512.00MB
2016-10-11T07:49:09.200609+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.03 sample#load_avg_5m=0.11 sample#load_avg_15m=1.05
2016-10-11T07:49:09.200662+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.95MB sample#memory_rss=360.66MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=198051pages sample#memory_pgpgout=110726pages sample#memory_quota=512.00MB
2016-10-11T07:49:29.065597+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.02 sample#load_avg_5m=0.11 sample#load_avg_15m=1.02
2016-10-11T07:49:29.065804+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.95MB sample#memory_rss=360.66MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=198051pages sample#memory_pgpgout=110726pages sample#memory_quota=512.00MB
2016-10-11T07:49:49.578417+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.01 sample#load_avg_5m=0.10 sample#load_avg_15m=1.00
2016-10-11T07:49:49.578512+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.96MB sample#memory_rss=360.67MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=199903pages sample#memory_pgpgout=112574pages sample#memory_quota=512.00MB
2016-10-11T07:50:09.507955+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.01 sample#load_avg_5m=0.09 sample#load_avg_15m=0.98
2016-10-11T07:50:09.508014+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.96MB sample#memory_rss=360.67MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=200902pages sample#memory_pgpgout=113573pages sample#memory_quota=512.00MB
2016-10-11T07:50:29.129918+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.01 sample#load_avg_5m=0.09 sample#load_avg_15m=0.96
2016-10-11T07:50:29.129999+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.96MB sample#memory_rss=360.67MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202212pages sample#memory_pgpgout=114883pages sample#memory_quota=512.00MB
2016-10-11T07:50:50.411750+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.01 sample#load_avg_5m=0.08 sample#load_avg_15m=0.93
2016-10-11T07:50:50.412262+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.96MB sample#memory_rss=360.67MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202242pages sample#memory_pgpgout=114913pages sample#memory_quota=512.00MB
2016-10-11T07:51:09.263292+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.08 sample#load_avg_15m=0.92
2016-10-11T07:51:09.263372+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.96MB sample#memory_rss=360.67MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202242pages sample#memory_pgpgout=114913pages sample#memory_quota=512.00MB
2016-10-11T07:51:29.351524+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.07 sample#load_avg_15m=0.90
2016-10-11T07:51:29.351576+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.96MB sample#memory_rss=360.67MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202242pages sample#memory_pgpgout=114913pages sample#memory_quota=512.00MB
2016-10-11T07:51:49.426565+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.07 sample#load_avg_15m=0.88
2016-10-11T07:51:49.426674+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.98MB sample#memory_rss=360.69MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202265pages sample#memory_pgpgout=114931pages sample#memory_quota=512.00MB
2016-10-11T07:52:09.152514+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.06 sample#load_avg_15m=0.86
2016-10-11T07:52:09.152567+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.98MB sample#memory_rss=360.69MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202265pages sample#memory_pgpgout=114931pages sample#memory_quota=512.00MB
2016-10-11T07:52:28.966231+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.06 sample#load_avg_15m=0.84
2016-10-11T07:52:28.966365+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.98MB sample#memory_rss=360.69MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202265pages sample#memory_pgpgout=114931pages sample#memory_quota=512.00MB
2016-10-11T07:52:49.245269+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.05 sample#load_avg_15m=0.82
2016-10-11T07:52:49.245324+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.98MB sample#memory_rss=360.69MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202265pages sample#memory_pgpgout=114931pages sample#memory_quota=512.00MB
2016-10-11T07:53:08.853746+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.05 sample#load_avg_15m=0.80
2016-10-11T07:53:08.853746+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.98MB sample#memory_rss=360.69MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202265pages sample#memory_pgpgout=114931pages sample#memory_quota=512.00MB
2016-10-11T07:53:28.806532+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.05 sample#load_avg_15m=0.78
2016-10-11T07:53:28.806608+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.98MB sample#memory_rss=360.69MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202265pages sample#memory_pgpgout=114931pages sample#memory_quota=512.00MB
2016-10-11T07:53:49.036866+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.04 sample#load_avg_15m=0.77
2016-10-11T07:53:49.036970+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=361.98MB sample#memory_rss=360.69MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202265pages sample#memory_pgpgout=114931pages sample#memory_quota=512.00MB
2016-10-11T07:54:09.127486+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.04 sample#load_avg_15m=0.75
2016-10-11T07:54:09.127588+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.00MB sample#memory_rss=360.71MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=202648pages sample#memory_pgpgout=115309pages sample#memory_quota=512.00MB
2016-10-11T07:54:29.870491+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.04 sample#load_avg_15m=0.73
2016-10-11T07:54:29.870583+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.00MB sample#memory_rss=360.71MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204441pages sample#memory_pgpgout=117102pages sample#memory_quota=512.00MB
2016-10-11T07:54:49.620217+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.04 sample#load_avg_15m=0.72
2016-10-11T07:54:49.620417+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.00MB sample#memory_rss=360.71MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204441pages sample#memory_pgpgout=117102pages sample#memory_quota=512.00MB
2016-10-11T07:55:09.770897+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.03 sample#load_avg_15m=0.70
2016-10-11T07:55:09.770983+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.00MB sample#memory_rss=360.71MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204523pages sample#memory_pgpgout=117184pages sample#memory_quota=512.00MB
2016-10-11T07:55:29.531150+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.03 sample#load_avg_15m=0.69
2016-10-11T07:55:29.531217+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.00MB sample#memory_rss=360.71MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204523pages sample#memory_pgpgout=117184pages sample#memory_quota=512.00MB
2016-10-11T07:55:49.893951+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.03 sample#load_avg_15m=0.67
2016-10-11T07:55:49.894082+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.01MB sample#memory_rss=360.71MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204525pages sample#memory_pgpgout=117185pages sample#memory_quota=512.00MB
2016-10-11T07:56:09.650640+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.03 sample#load_avg_15m=0.66
2016-10-11T07:56:09.650724+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.02MB sample#memory_rss=360.73MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204547pages sample#memory_pgpgout=117203pages sample#memory_quota=512.00MB
2016-10-11T07:56:30.254665+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.03 sample#load_avg_15m=0.64
2016-10-11T07:56:30.254762+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.02MB sample#memory_rss=360.73MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204547pages sample#memory_pgpgout=117203pages sample#memory_quota=512.00MB
2016-10-11T07:56:48.850281+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.02 sample#load_avg_15m=0.63
2016-10-11T07:56:48.850357+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.03MB sample#memory_rss=360.73MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204548pages sample#memory_pgpgout=117203pages sample#memory_quota=512.00MB
2016-10-11T07:57:08.835429+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.00 sample#load_avg_5m=0.02 sample#load_avg_15m=0.61
2016-10-11T07:57:08.835482+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.03MB sample#memory_rss=360.73MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204548pages sample#memory_pgpgout=117203pages sample#memory_quota=512.00MB
2016-10-11T07:57:29.343623+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.29 sample#load_avg_5m=0.09 sample#load_avg_15m=0.62
2016-10-11T07:57:29.343738+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.03MB sample#memory_rss=360.73MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204548pages sample#memory_pgpgout=117203pages sample#memory_quota=512.00MB
2016-10-11T07:57:48.939922+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.21 sample#load_avg_5m=0.08 sample#load_avg_15m=0.61
2016-10-11T07:57:48.940024+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.03MB sample#memory_rss=360.73MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204548pages sample#memory_pgpgout=117203pages sample#memory_quota=512.00MB
2016-10-11T07:58:09.362342+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.15 sample#load_avg_5m=0.08 sample#load_avg_15m=0.60
2016-10-11T07:58:09.362391+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.05MB sample#memory_rss=360.75MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204572pages sample#memory_pgpgout=117222pages sample#memory_quota=512.00MB
2016-10-11T07:58:30.066368+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.11 sample#load_avg_5m=0.06 sample#load_avg_15m=0.04
2016-10-11T07:58:30.066470+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=362.05MB sample#memory_rss=360.75MB sample#memory_cache=0.42MB sample#memory_swap=0.88MB sample#memory_pgpgin=204573pages sample#memory_pgpgout=117223pages sample#memory_quota=512.00MB
2016-10-11T07:58:48.925643+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.08 sample#load_avg_5m=0.06 sample#load_avg_15m=0.04
2016-10-11T07:58:48.925754+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=372.02MB sample#memory_rss=370.65MB sample#memory_cache=0.56MB sample#memory_swap=0.81MB sample#memory_pgpgin=206669pages sample#memory_pgpgout=117260pages sample#memory_quota=512.00MB
2016-10-11T07:59:09.219354+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.05 sample#load_avg_5m=0.05 sample#load_avg_15m=0.04
2016-10-11T07:59:09.219427+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=372.02MB sample#memory_rss=370.65MB sample#memory_cache=0.56MB sample#memory_swap=0.81MB sample#memory_pgpgin=208341pages sample#memory_pgpgout=118932pages sample#memory_quota=512.00MB
2016-10-11T07:59:29.028619+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.04 sample#load_avg_5m=0.05 sample#load_avg_15m=0.04
2016-10-11T07:59:29.028691+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=372.02MB sample#memory_rss=370.65MB sample#memory_cache=0.56MB sample#memory_swap=0.81MB sample#memory_pgpgin=208341pages sample#memory_pgpgout=118932pages sample#memory_quota=512.00MB
2016-10-11T07:59:49.632499+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#load_avg_1m=0.03 sample#load_avg_5m=0.05 sample#load_avg_15m=0.04
2016-10-11T07:59:49.632499+00:00 heroku[web.1]: source=web.1 dyno=heroku.57768658.b9f48709-d075-4276-84b4-6ece6c0b3a83 sample#memory_total=372.02MB sample#memory_rss=370.65MB sample#memory_cache=0.56MB sample#memory_swap=0.81MB sample#memory_pgpgin=208341pages sample#memory_pgpgout=118932pages sample#memory_quota=512.00MB
2016-10-11T07:59:57.656626+00:00 heroku[web.1]: Idling
2016-10-11T07:59:57.657322+00:00 heroku[web.1]: State changed from up to down
2016-10-11T08:00:01.813526+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-10-11T08:00:03.144058+00:00 app[web.1]: - Gracefully stopping, waiting for requests to finish
2016-10-11T08:00:03.225204+00:00 app[web.1]: === puma shutdown: 2016-10-11 08:00:03 +0000 ===
2016-10-11T08:00:03.225277+00:00 app[web.1]: - Goodbye!
2016-10-11T08:00:03.225400+00:00 app[web.1]: Exiting
2016-10-11T08:00:04.044624+00:00 heroku[web.1]: Process exited with status 0

@ce07c3
Copy link

ce07c3 commented Oct 14, 2016

Same here.

@schneems
Copy link
Contributor

Can you reproduce the memory increase locally? Can you provide us with an example app that shows the problem?

@nateberkopec
Copy link
Member

nateberkopec commented Nov 2, 2016

I've done some poking around, here's what I've learned:

  • I can reproduce this memory creep on Heroku using the steps provided in the original issue.
  • I cannot reproduce this memory creep locally on macOS Sierra. This may be due to the differences between Linux and MacOS memory management.
  • I cannot reproduce this memory creep on Heroku with thin. It does seem to be a Puma-specific issue.
  • This memory creep occurs regardless of using glibc malloc or jemalloc via the jemalloc buildpack.
  • Tuning any number of MALLOC env variables, such MALLOC_ARENA_MAX or even MALLOC_MMAP_THRESHOLD etc has no effect.
  • I cannot reproduce unbounded RSS creep in any environment, though I can reproduce (seemingly) unbounded total memory creep. See next point.
  • Eventually, the process starts swapping, slowly as shown in this comment. I can reproduce this. RSS grows slightly, then decreases as memory is swapped out. RSS does not grow unbounded.
  • Locally, I have observed some interestingly different behavior between puma and thin. Logging GC.stat to the console every 5 seconds, live_slots seems to increase slowly but consistently with puma, but not with thin. So Puma is clearly creating some ruby object garbage every X seconds that thin does not. @evanphx may be able to tell us where this occurs. Aside: In fact, with thin, heap_free_slots seems to slowly increase without running a GC. I am not sure how this is possible.
  • If I run GC.start every 5 seconds, causing a major GC, heap_live_slots does not increase under Puma. So there are no managed object leaks. Also, when running major GC every 5 seconds, I can almost completely negate all memory growth.

So, here is my hypothesis for what is happening:

  • Puma generates some Ruby object garbage when idling, which other webservers do not, probably because they make greater use of C-extensions and manage their memory outside of the Ruby VM.
  • Because of this, Puma slowly and gradually fills up free heap slots (marking them as "live").
  • This Ruby object garbage is not a leak, because running a major GC cleans it up.
  • However, generating this Ruby object garbage moves memory from the virtual set into the resident set as memory locations are accessed and memory mappings are created. This is what causes the RSS growth, not any memory leak.
  • puma can decide whether or not this memory growth is a problem, but the fact is that there is no leak demonstrated by this issue, what is being demonstrated is ordinary memory behavior in a UNIX system.

If you do not understand the difference between resident set size, virtual memory and physical memory I would encourage you to read this. Please do correct me if my understanding is wrong.

Important note: Several people in this issue have claimed large amounts of unbounded RSS growth, though no one has produced a repro app for this problem.

I used the following code to run/track GC:

Thread.new do
  # hash = {}
  while true
    sleep(5)
    # puts GC.stat(hash)
    GC.start
  end
end

EDIT: After writing this, I learned that MRI does not use MMAP, so thats why that setting had no effect.

@nateberkopec
Copy link
Member

A couple of open questions I still have re: what I posted yesterday

  • This "problem" (~10-20MB of memory growth over 24 hours or so from an idle process) is also frequently raised on the Sidekiq repo. Is what we're seeing here (and my explanation for why) the same issue?
  • Why are we seeing this slow memory growth on Heroku but not on macOS? BSD's memory management is very different from Linux, but I still don't know exactly why there's a difference in the end result here.
  • I should be able to come up with a very simple example Ruby app to replicate this behavior - it should generate ~100 or so garbage objects every few seconds w/o GC, and then we should see the same memory creep occurring.
  • Because Heroku is Heroku, I couldn't see if the virtual set size of the process was increasing or not. I should try to replicate this issue in a non-containerized Linux environment, and maybe get some better memory introspection with smaps or something.

@schneems
Copy link
Contributor

schneems commented Nov 3, 2016

Sometimes I feel like memory work is like working with divining rods.

My internal theory for why this is normal is that this +10-20mb is where the Ruby process actually wants to be to be "comfortable" with the amount of memory it has. Ruby processes start with notoriously small heaps and it depending on the random place in your code when a major GC gets kicked off, you may or may not need those "junk" objects. It keeps on increasing until it finds its max.

I'm not totally convinced that this isn't happening on a mac or another OS. Few people leave open processes running for 24 hours and have a minute-by-minute graph of the different memory statistics (no I don't think that new relic is reliable). Also different OS tools might report memory differently. Maybe macs give a starting process more memory than it thinks it will need by default and just happens to be in the 10-20mb range so you never observe memory going up, even though utilized memory inside of the process is going up.

If this memory increasing problem really isn't happening on mac, one difference could be the implementation of malloc, perhaps OS X is more aggressive about free-ing. This would make more sense for a general purpose OS that doesn't want one long lived process to eat all the resources versus linux where it is very common and desirable to have a handful of extremely long lived processes that you want to consume all the resources (a webserver for example, you want to have max performance, hence max resources).

Another difference could be the LXC container we are running things in.

These are all theories.

@nateberkopec
Copy link
Member

My internal theory for why this is normal is that this +10-20mb is where the Ruby process actually wants to be to be "comfortable" with the amount of memory it has. Ruby processes start with notoriously small heaps

The problem with this theory is that the number of heap pages is not increasing.

Also different OS tools might report memory differently.

this is true. on Mac I was using ps, Heroku reports <cgroupfs>/memory.stat

one difference could be the implementation of malloc, perhaps OS X is more aggressive about free-ing

If my hypothesis is correct, the difference is actually in the MMU/kernel, not malloc. Worth noting that using jemalloc does not change the demonstrated behavior.

@jrafanie
Copy link

jrafanie commented Nov 3, 2016

@nateberkopec very interesting summary of your findings. Thanks for digging into it.

Can you confirm if you're using the defaults for min_threads (0), max_threads(16), and workers (0) (clustered mode disabled)?

tldr; let's clarify fork or not...because....

Note, I ask because clustered mode uses fork and ruby's GC 2.1+ fork is not very fork friendly since shared pages are slowly copied to private pages. I've never really documented what we've found but basically any writes to the shared pages, even freeing a single memory location on the page, causes a copy on write of the whole page. We've found that shared memory as reported by /proc//smaps is mostly shared (60-80%) just after fork but gradually drops to (10-30%) shared within several minutes.

Tuning any number of MALLOC env variables, such MALLOC_ARENA_MAX or even MALLOC_MMAP_THRESHOLD etc has no effect.

Are you using glibc 2.10+? How many threads are in your puma process?

In my experience, if you're using more than a and MALLOC_ARENA_MAX isn't set, resident/virtual memory will rise significantly with NO increase in the heap_available_slots as reported by GC.stat.

@nateberkopec
Copy link
Member

Can you confirm if you're using the defaults for min_threads (0), max_threads(16), and workers (0) (clustered mode disabled)?

I was using Rails 5, which I believe has a min_threads setting of 5 and max-threads of 5 by default. Workers were still 0, so no forking.

Are you using glibc 2.10+?

I don't believe the glibc version matters because this behavior can be shown with glibc malloc or jemalloc.

@jrafanie
Copy link

jrafanie commented Nov 3, 2016

Note, this and the other puma memory issues might look like some of us are complaining but honestly, this is really interesting... I'm sure with more people 👀 who can provide their details/symptoms and expertise, we'll figure this out. 👏

@nateberkopec in your comparison, did you use thin in threaded mode or use the default of "non-threaded"?
https://github.com/macournoyer/thin/blob/a7d1174f47a4491a15b505407c0501cdc8d8d12c/lib/thin/backends/base.rb#L55

@jrafanie
Copy link

jrafanie commented Nov 3, 2016

I don't believe the glibc version matters because this behavior can be shown with glibc malloc or jemalloc.

Good point @nateberkopec. This is clearly different than other reported issues where the arena max setting mattered.

If I run GC.start every 5 seconds, causing a major GC, heap_live_slots does not increase under Puma. So there are no managed object leaks. Also, when running major GC every 5 seconds, I can almost completely negate all memory growth.

So, I've had this gut feeling that ruby's GC is allocation based and how this could cause us to not do a full GC for a long time if we time it "wrong". If you do lots of allocations, grow the heap size and continue to allocate objects, everything is fine because the full GCs will triggered on allocations and will happen somewhat regularly. But, if you have ups and downs where full GCs don't occur for a long time during the downs, you might accumulate lots of live slots that could be GC'd but aren't.

@Fryguy
Copy link

Fryguy commented Nov 3, 2016

So, I've had this gut feeling that ruby's GC is allocation based and how this could cause us to not do a full GC for a long time if we time it "wrong".

The GC is not aware of the underlying size of the Ruby objects, you can create a single Ruby object backed by 1GB of heap allocated memory and Ruby has no idea, so it won't kick off a GC. It's Ruby's world, you only created one object in the Ruby heap, and there are plenty of slots leftover.

So, on that note, I'm wondering if an idling puma is creating a small enough number of Ruby objects to not trigger the GC, but that are backed by much larger heap allocated memory blocks.

@nateberkopec
Copy link
Member

So, on that note, I'm wondering if an idling puma is creating a small enough number of Ruby objects to not trigger the GC, but that are backed by much larger heap allocated memory blocks.

Hmm, interesting idea.

To simplify the reproduction of this behavior, check out https://github.com/nateberkopec/pumagarbotest which is a bare rack app that repros the original issue.

@nateberkopec
Copy link
Member

The GC is not aware of the underlying size of the Ruby objects, you can create a single Ruby object backed by 1GB of heap allocated memory and Ruby has no idea, so it won't kick off a GC. It's Ruby's world, you only created one object in the Ruby heap, and there are plenty of slots leftover.

This isn't correct. Try the following code:

Thread.new do
  prev_result = {}
  while true
    sleep(5)
    str = "0" * 9999999
    hash = GC.stat
    diff = hash.merge(prev_result) { |k,ov,nv| 0 - (nv - ov) }
    puts diff.reject! { |k,v| v == 0 }
    prev_result = hash
    #GC.start
  end
end

Basically we're allocating a humongous string every 5 seconds, then diffing GC.stat with the previous run. Note how a GC is triggered every ~20-30 seconds or so.

This behavior of GC-triggered-by-heap-allocation is governed by GC_MALLOC_LIMIT and GC_OLDMALLOC_LIMIT in Ruby 2.3. In particular I think the GC is triggered here.

So, on that note, I'm wondering if an idling puma is creating a small enough number of Ruby objects to not trigger the GC, but that are backed by much larger heap allocated memory blocks.

That said, I think this is probably the case. Puma is creating some heap-backed objects (long strings, etc) while idling. This calls malloc (I think here) which causes that slow RSS creep we're seeing.

@Fryguy
Copy link

Fryguy commented Nov 3, 2016

Strings seem to work differently (I was over-generalizing 😄) probably because Ruby is aware of the memory being allocated. I'm more thinking of DataWrapStruct stuff in a C extension wrapping around a large amount of malloced memory...I saw the statement "they make greater use of C-extensions and manage their memory outside of the Ruby VM" up above and thats why this popped in my head.

@nateberkopec
Copy link
Member

Alright, I'm 99% convinced this is normal behavior of heap growth outside the objectspace. No one's actually shown any behavior/produced a repro app that points to a memory leak.

The fact that the repro app only repros on Heroku (Ubuntu) and not on macOS just further proves that this is just the behavior of malloc and the kernel, not anything in Rubyland.

@hakusaro
Copy link

hakusaro commented Jan 9, 2017

I hate to bump a thread this old, but I believe this is still an issue. Heroku is a fairly big platform that many people use -- and their own help guides actually suggest using Puma as the preferred Ruby web server.

Does the hack of just running GC.start every 5 seconds on every worker actually work? While it's certainly a hack, it definitely beats memory consumption going out of control. I just spent several hours migrating a side project from to use Puma, only to crash straight into this issue. The memory use is fairly clear (switched from using Thin to Puma) -- and I understand that it's a super hacky solution, but if it works...it works?

screen shot 2017-01-09 at 2 23 46 am

Coincidentally moved to Puma after reading this article by you, nateberkopec.

@nateberkopec
Copy link
Member

Does the hack of just running GC.start every 5 seconds on every worker actually work?

To be 100% clear, you Should Not Do This in production. That is not a workaround. I only included it in the script for demonstration purposes.

@hakusaro
Copy link

hakusaro commented Jan 9, 2017

@nateberkopec while I'm certainly aware that it works it's a workaround, I'd say that puma_worker_killer's equally silly solution (or setting up a cronjob to run heroku restart every hour) are bad if not worse than just aggressively telling the gc to run. That's just my two cents, though. The activity on this issue probably disappeared when people realized that was a cheap and dirty fix to a fairly large problem.

@nateberkopec
Copy link
Member

@nicatronTg If a GC reduces memory usage, you don't have a leak. The definition of a leak is an unmanaged growth on the heap. If you can free memory by garbage collecting it, you've just got either poor GC settings or a weird workload.

If running GC.start fixes your problems, you may want to to watch my 2016 RubyConf talk about 12 ways to reduce memory usage in Ruby applications.

@hakusaro
Copy link

hakusaro commented Jan 10, 2017

@nateberkopec it doesn't fix the problem for me, but in the context of this thread, or at least the way I read your comment, it seemed to mitigate heap_free_slots growth when it would normally increase over time (if I've read that right).

@nateberkopec
Copy link
Member

I'm going to close this issue. If you have an issue with memory growth on Puma please try the following:

If you've tried all of the above and still have problems and can provide a reproduction application with just Puma that grows significantly in a short amount of time, I am happy to reopen.

@hakusaro
Copy link

I'd like to just point out that on Heroku-land, a few months ago with no changes to my code this magically stopped being an issue. I don't remember the exact date but after a scheduled dyno restart I've yet to experience uncontrolled growth ever again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests