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 leak possible #1097

Open
huacnlee opened this issue Oct 30, 2022 · 2 comments
Open

Memory leak possible #1097

huacnlee opened this issue Oct 30, 2022 · 2 comments

Comments

@huacnlee
Copy link

huacnlee commented Oct 30, 2022

By use derailed_benchmarks

$ bundle exec derailed exec perf:objects
bundle exec derailed exec perf:objects
Booting: production
Database 'foo_development' already exists
Endpoint: "/"
Running 1 times
Total allocated: 251707 bytes (5728 objects)
Total retained:  40040 bytes (1001 objects)

allocated memory by gem
-----------------------------------
    200544  foo/app
     10835  activesupport-7.0.4
     10406  actionpack-7.0.4
      7961  rack-2.2.4
      5136  hashie-5.0.0
      3398  other
      2560  actionview-7.0.4
      2392  ipaddr
      2088  logger
      1376  uri
      1193  railties-7.0.4
       760  activerecord-7.0.4
       664  warden-1.2.9
       634  random
       544  omniauth-2.1.0
       416  concurrent-ruby-1.1.10
       400  delegate
       240  monitor
        80  securerandom
        80  set

....

retained memory by gem
-----------------------------------
     40000  foo/app
        40  activesupport-7.0.4

retained memory by file
-----------------------------------
     40000  /Users/jason/Downloads/foo/app/controllers/welcome_controller.rb
        40  /Users/jason/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.4/lib/active_support/current_attributes.rb

retained memory by location
-----------------------------------
     40000  /Users/jason/Downloads/foo/app/controllers/welcome_controller.rb:3
        40  /Users/jason/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.4/lib/active_support/current_attributes.rb:213

retained memory by class
-----------------------------------
     40000  String
        40  Hash

retained objects by gem
-----------------------------------
      1000  foo/app
         1  activesupport-7.0.4

retained objects by file
-----------------------------------
      1000  /Users/jason/Downloads/foo/app/controllers/welcome_controller.rb
         1  /Users/jason/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.4/lib/active_support/current_attributes.rb

retained objects by location
-----------------------------------
      1000  /Users/jason/Downloads/foo/app/controllers/welcome_controller.rb:3
         1  /Users/jason/.rbenv/versions/3.1.0/lib/ruby/gems/3.1.0/gems/activesupport-7.0.4/lib/active_support/current_attributes.rb:213

retained objects by class
-----------------------------------
      1000  String
         1  Hash

In config/initializers/devise.rb if I disable the omniauth, the leaks gone.

Devise.setup do |config|
  # config.omniauth :github, "APP_ID", "APP_SECRET", scope: "user,public_repo"
end

I do this test because there have a production project was find memory leaks in recently.


Here is an example project for help us to test.

https://github.com/huacnlee/omniauth-memory-test

@BobbyMcWho
Copy link
Member

That only runs the test one time, what happens when you

TEST_COUNT=10 bundle exec derailed exec perf:objects

@huacnlee
Copy link
Author

huacnlee commented Oct 30, 2022

Same, I have updated the example project.

OmniAuth 2.1

gem "omniauth", "~> 2.1"
gem "omniauth-github"

Output:

bundle exec derailed exec perf:objects
Booting: production
Database 'foo_development' already exists
Endpoint: "/"
Running 1 times
Total allocated: 50367 bytes (710 objects)
Total retained:  40 bytes (1 objects)

OmniAuth 1.9

gem "omniauth", "~> 1.9"
gem "omniauth-github", "~> 1.4"
bundle exec derailed exec perf:objects
Booting: production
Database 'foo_development' already exists
Endpoint: "/"
Running 1 times
Total allocated: 50247 bytes (707 objects)
Total retained:  1504 bytes (9 objects)

https://github.com/huacnlee/omniauth-memory-test

huacnlee added a commit to ruby-china/homeland that referenced this issue Oct 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants