-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
improve isWindows method in HashedWheelTimer #6845
Conversation
this change makes sense to me and will merge soon when CI pass. Another thing is current way to check OS maybe not good enough. there are many utils can do similar work: Maybe this is something we can improve in the future |
Codecov Report
@@ Coverage Diff @@
## master #6845 +/- ##
============================================
- Coverage 59.15% 59.00% -0.15%
+ Complexity 510 506 -4
============================================
Files 1028 1028
Lines 41534 41535 +1
Branches 6041 6041
============================================
- Hits 24570 24509 -61
- Misses 14194 14244 +50
- Partials 2770 2782 +12 Continue to review full report at Codecov.
|
thanks for your contribution :) |
improve isWindows method in HashedWheelTimer (apache#6845)
Memory usage is too high。frequently GC
发现所有分支皆有此问题,则提交到主分支
#6820
#6808
bug 所在文件 https://github.com/apache/dubbo/blob/master/dubbo-common/src/main/java/org/apache/dubbo/common/timer/HashedWheelTimer.java
出现问题的方法:
private boolean isWindows() { return System.getProperty("os.name", "").toLowerCase(Locale.US).contains("win"); }
问题产生原因:
1.waitForNextTick() 中无限调用 isWindows();
2.toLowerCase(Locale.US) 将急速产生 char[] 对象。导致内存占用过高。
解决方案:
` private static boolean isWindows = System.getProperty("os.name", "").toLowerCase(Locale.US).contains("win");
private boolean isWindows() {
return isWindows;
}`
close #6820