This project is archived and is in readonly mode.

#1552 ✓committed
Edward Waller

Memory Problem with config.log_level = :warn

Reported by Edward Waller | December 10th, 2008 @ 09:13 PM

Rails 2.2+ has this problem (testing on Rails HEAD)

So, in Rails 2.2+, there seems to be some memory problems with using config.log_level = :warn. Below I show the steps to reproduce this.

Creating project


compy:Rails Eddie$ rails logger_problem
      create  
      create  app/controllers
      create  app/helpers
      create  app/models
      create  app/views/layouts
      create  config/environments
      create  config/initializers
      create  config/locales
      create  db
      create  doc
      create  lib
      create  lib/tasks
      create  log
      create  public/images
      create  public/javascripts
      create  public/stylesheets
      create  script/performance
      create  script/process
      create  test/fixtures
      create  test/functional
      create  test/integration
      create  test/performance
      create  test/unit
      create  vendor
      create  vendor/plugins
      create  tmp/sessions
      create  tmp/sockets
      create  tmp/cache
      create  tmp/pids
      create  Rakefile
      create  README
      create  app/controllers/application.rb
      create  app/helpers/application_helper.rb
      create  test/test_helper.rb
      create  test/performance/browsing_test.rb
      create  config/database.yml
      create  config/routes.rb
      create  config/initializers/inflections.rb
      create  config/initializers/mime_types.rb
      create  config/initializers/new_rails_defaults.rb
      create  config/locales/en.yml
      create  config/boot.rb
      create  config/environment.rb
      create  config/environments/production.rb
      create  config/environments/development.rb
      create  config/environments/test.rb
      create  script/about
      create  script/console
      create  script/dbconsole
      create  script/destroy
      create  script/generate
      create  script/performance/benchmarker
      create  script/performance/profiler
      create  script/performance/request
      create  script/process/reaper
      create  script/process/spawner
      create  script/process/inspector
      create  script/runner
      create  script/server
      create  script/plugin
      create  public/dispatch.rb
      create  public/dispatch.cgi
      create  public/dispatch.fcgi
      create  public/404.html
      create  public/422.html
      create  public/500.html
      create  public/index.html
      create  public/favicon.ico
      create  public/robots.txt
      create  public/images/rails.png
      create  public/javascripts/prototype.js
      create  public/javascripts/effects.js
      create  public/javascripts/dragdrop.js
      create  public/javascripts/controls.js
      create  public/javascripts/application.js
      create  doc/README_FOR_APP
      create  log/server.log
      create  log/production.log
      create  log/development.log
      create  log/test.log
compy:Rails Eddie$ cd logger_problem/
compy:logger_problem Eddie$ cp -R ../test_project/vendor/rails vendor/
compy:logger_problem Eddie$ script/generate resource tasks
      exists  app/models/
      exists  app/controllers/
      exists  app/helpers/
      create  app/views/tasks
      exists  test/functional/
      exists  test/unit/
      create  test/unit/helpers/
  dependency  model
      exists    app/models/
      exists    test/unit/
      exists    test/fixtures/
      create    app/models/tasks.rb
      create    test/unit/tasks_test.rb
      create    test/fixtures/tasks.yml
      create    db/migrate
      create    db/migrate/20081210205128_create_tasks.rb
      create  app/controllers/tasks_controller.rb
      create  test/functional/tasks_controller_test.rb
      create  app/helpers/tasks_helper.rb
      create  test/unit/helpers/tasks_helper_test.rb
       route  map.resources :tasks
compy:logger_problem Eddie$ rake db:migrate
(in /Users/Eddie/Projects/Rails/logger_problem)
==  CreateTasks: migrating ====================================================
-- create_table(:tasks)
   -> 0.0041s
==  CreateTasks: migrated (0.0044s) ===========================================

Editing files

I added an index action, created index.html.erb, and set config.log_level = :warn


diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb
index 1ad33d0..22407f0 100644
--- a/app/controllers/tasks_controller.rb
+++ b/app/controllers/tasks_controller.rb
@@ -1,2 +1,5 @@
 class TasksController < ApplicationController
+  def index
+    
+  end
 end
diff --git a/config/environments/production.rb b/config/environments/production.rb
index ec5b7bc..996f8eb 100644
--- a/config/environments/production.rb
+++ b/config/environments/production.rb
@@ -22,3 +22,5 @@ config.action_controller.perform_caching             = true

 # Disable delivery errors, bad email addresses will be ignored
 # config.action_mailer.raise_delivery_errors = false
+
+config.log_level = :warn

Starting Server


compy:logger_problem Eddie$ script/server -e production
=> Booting Mongrel
=> Rails 2.3.0 application starting on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server

Hitting it with httperf to simulate requests


compy:vendor Eddie$  ps -e -o vsz,pid,ppid,args | grep server
  104660 21431 21366 script/server -e production
compy:vendor Eddie$ httperf --server localhost --port 3000 --uri /tasks --num-conns 1000 > /dev/null 
compy:vendor Eddie$  ps -e -o vsz,pid,ppid,args | grep server
  126672 21431 21366 script/server -e production
compy:vendor Eddie$ httperf --server localhost --port 3000 --uri /tasks --num-conns 1000 > /dev/null 
compy:vendor Eddie$  ps -e -o vsz,pid,ppid,args | grep server
  147612 21431 21366 script/server -e production

As you should be able to see above, the memory usage (first column) grows quite a bit with each 1000 requests. Commenting out the config.log_level = :warn line stops this behavior.

If you need any more info I'd be happy to help.

Comments and changes to this ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

<h2 style="font-size: 14px">Tickets have moved to Github</h2>

The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>

People watching this ticket

Attachments

Referenced by

Pages