Dominic Goulet
Dominic Goulet

Reputation: 8113

Memory issue in my rails engine?

I have a quite small Rails 3.1.1 application that rack up memory at lightning speed. 8-10 clicks in the application and I'm up to almost 1gb of RAM used.

We checked the log for slow running MYSQL queries, nothing there. We also checked Apache log, nothing there.

The application is running with Passenger 3.0

Can this issue be bound to some gem that is used? This application started as a Rails 3.0.1 application, and we updated the rails version. There are still [deprecated?] references in the gemfile. Here is the gemfile :

gem "rails", "~> 3.1.1"
gem "mysql2", "~> 0.3.6"
gem 'omniauth', '0.2.6'
gem 'json'

group :assets do
  gem "sass-rails", "~> 3.1.4"
  gem "coffee-rails", "~> 3.1.1"
  gem 'uglifier'
end

gem 'jquery-rails'
gem 'execjs'
gem 'therubyracer'
gem 'capistrano'

Thanks

Upvotes: 1

Views: 366

Answers (3)

jimp2
jimp2

Reputation: 11

Because therubyracer gem.

therubyracer with passenger make memroy leak.

delete therubyracer gem or use 0.7.5 version

Upvotes: 1

Daan
Daan

Reputation: 10314

It is all about eliminating possibilities. Some directions:

  • Does the application run in development mode? Is there a difference in memory usage in development / production mode?
  • Try staying on one page, in one controller. Monitor the memory continuously. Is it going up? Is it only one controller or in all controllers? If it is in one controller only, you have a smaller codebase to check.
  • Memory profile your application with tools like Bleakhouse, Memorylogic, Scout or New Relic. Check the memory hotspots to find the memory hog.
  • Eliminate dependencies one by one, to see if a bug in another gem is causing the problem.
  • Try a different server, like Mongrel, WEBrick or Unicorn. If the behaviour is different, it could be Passenger.
  • Try a different Ruby version to see if the problem persists.

Upvotes: 2

Marnen Laibow-Koser
Marnen Laibow-Koser

Reputation: 6337

Instead of slow queries, check for inefficient queries -- that is, the kind that load lots of records from the DB, create lots of objects, and then loop over them on the Ruby side.

Or use a profiler such as New Relic.

Upvotes: 0

Related Questions