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

[balancer] fix memory leak in round-robin balancer #345

Merged
merged 1 commit into from
Apr 3, 2017

Conversation

mikz
Copy link
Contributor

@mikz mikz commented Apr 3, 2017

using LRU cache with max entries to limit number of counters it is kept in memory

Testing using TEST_NGINX_CHECK_LEAK

before

/016-balancer.t .. TEST 1: round robin does not leak memory
WARNING: method GET not supported for ab when taking a request body
LeakTest: [5768 5964 5964 6192 6224 6224 6500 6500 6500 6760 6788 6788 6928 7088 7088 7088 7532 8300 8300 8300 8300 8300 8856 9672 10084 10084 10084 10084 10084 10584 10584 10584 10584 10584 10776 11112 11112 11112 11112 11112 11460 11668 11668 11668 11668 11668 11872 12256 12256 12256 12256 12256 12256 12732 12872 12872 13128 14664 14664 14664 14664 14664 14664 14664 14664 15168 15968 16740 17500 18088 18164 18164 18164 18164 18164 18164 18164 18164 18164 18164 18460 19080 19144 19144 19144 19144 19144 19144 19144 19144 19144 19144 19144 19636 20164 20164 20164 20164 20164 20164]
LeakTest: k=158.8
t/016-balancer.t .. ok
All tests successful.
Files=1, Tests=4,  6 wallclock secs ( 0.03 usr  0.00 sys +  1.21 cusr  3.91 csys =  5.15 CPU)
Result: PASS

after

t/016-balancer.t .. TEST 1: round robin does not leak memory
WARNING: method GET not supported for ab when taking a request body
LeakTest: [2248 2248 2248 2248 2248 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252]
LeakTest: k=0.0
t/016-balancer.t .. ok
All tests successful.
Files=1, Tests=4,  6 wallclock secs ( 0.02 usr  0.01 sys +  1.15 cusr  3.55 csys =  4.73 CPU)
Result: PASS

before:

/016-balancer.t .. TEST 1: round robin does not leak memory
WARNING: method GET not supported for ab when taking a request body
LeakTest: [5768 5964 5964 6192 6224 6224 6500 6500 6500 6760 6788 6788 6928 7088 7088 7088 7532 8300 8300 8300 8300 8300 8856 9672 10084 10084 10084 10084 10084 10584 10584 10584 10584 10584 10776 11112 11112 11112 11112 11112 11460 11668 11668 11668 11668 11668 11872 12256 12256 12256 12256 12256 12256 12732 12872 12872 13128 14664 14664 14664 14664 14664 14664 14664 14664 15168 15968 16740 17500 18088 18164 18164 18164 18164 18164 18164 18164 18164 18164 18164 18460 19080 19144 19144 19144 19144 19144 19144 19144 19144 19144 19144 19144 19636 20164 20164 20164 20164 20164 20164]
LeakTest: k=158.8
t/016-balancer.t .. ok
All tests successful.
Files=1, Tests=4,  6 wallclock secs ( 0.03 usr  0.00 sys +  1.21 cusr  3.91 csys =  5.15 CPU)
Result: PASS

after:

t/016-balancer.t .. TEST 1: round robin does not leak memory
WARNING: method GET not supported for ab when taking a request body
LeakTest: [2248 2248 2248 2248 2248 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252 2252]
LeakTest: k=0.0
t/016-balancer.t .. ok
All tests successful.
Files=1, Tests=4,  6 wallclock secs ( 0.02 usr  0.01 sys +  1.15 cusr  3.55 csys =  4.73 CPU)
Result: PASS
@mikz mikz force-pushed the balancer-memory-leak branch from 28bed30 to 70df5a3 Compare April 3, 2017 06:13
@mikz mikz merged commit 7558fda into master Apr 3, 2017
@mikz mikz deleted the balancer-memory-leak branch April 3, 2017 06:20
@macejmic
Copy link

macejmic commented Apr 3, 2017

🍤

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

Successfully merging this pull request may close these issues.

2 participants