I can't figure out why my Rails app (hosted on Heroku (cedar)) keeps allocating more and more memory. If I didn't know any better I'd say that this a memory leak in Ruby/Rails, but since I'm completely new to Ruby/Rails, I feel like I'm missing something completely obvious.
I'm using Rails defaults generated by rails new
, and completely up-to-date gems:
source 'https://rubygems.org'
gem 'rails', '3.2.8'
group :development do
gem 'sqlite3'
end
group :assets do
gem "sass-rails", "~> 3.2.5"
gem "coffee-rails", "~> 3.2.2"
gem "uglifier", "~> 1.3.0"
end
gem "jquery-rails", "~> 2.1.2"
group :production do
gem 'newrelic_rpm'
gem "pg", "~> 0.14.1"
end
I'm using the default newrelic config. I have zero models and one controller, nothing_controller.rb
, which was generated using rails generate controller nothing
:
class NothingController < ApplicationController
def index
end
end
I deleted public/index.html
and added an empty views/nothing/index.html.erb
. The only other thing I did to the generated app was add a route to routes.rb
:
Nothing::Application.routes.draw do
root :to => "nothing#index"
end
I committed, pushed it to Heroku, then wrote a quick script that would load my Heroku page every 10 seconds. This is what my New Relic reports:
That's all there is to it. Memory just keeps increasing like that until it passes Heroku's limit of 512MB. The code in this app is pretty much the same as the code I've seen in the tutorial I followed. I don't understand what I'm doing wrong.
Any guidance would be greatly appreciated.
EDIT (9/12): In case it's relevant, I'm using ruby 1.9.
Code I'm using to hit the server (C#):
using (var wc = new WebClient())
for (;; Thread.Sleep(10000))
wc.DownloadString("http://vast-earth-9859.herokuapp.com/");
EDIT (9/13): Going to try disabling New Relic and seeing if it still R14s.
Instantiation Breakdown: Total: 0
, as expected) but I can't figure out how to use it on Heroku. Logs aren't stored in logs/* and a cursory Google search did not tell me much. I don't get it though...is something wrong with my Rails or something? I feel like I'm the only one with this problem. How does everyone else's heroku+rails apps not run out of memory? – Antalkali