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

[type:fix] fix memory leak #4486

Merged
merged 10 commits into from
Mar 17, 2023
Merged

[type:fix] fix memory leak #4486

merged 10 commits into from
Mar 17, 2023

Conversation

moremind
Copy link
Member

@moremind moremind commented Mar 16, 2023

Fixes #4475

testcase from #4475, testcase as follows:

public class TestMemoryLeak {
    
    // 1m内存
    private static final int M_1 = 1 * 1024 * 1024;
    public static void main(String[] args) throws InterruptedException, IOException {
        try {
            mswtMapTest();
        } catch (Exception e) {
            e.printStackTrace();
        }
        TimeUnit.SECONDS.sleep(Long.MAX_VALUE);
    }
    
    public static void mswtMapTest() {
        for (int i = 0; i < 10; i++) {
            WindowTinyLFUMap<String, Byte[]> map = new WindowTinyLFUMap<>(1, 100, Boolean.TRUE);
            map.put(String.valueOf(i), new Byte[M_1 * 2]);
            // 手动GC
        }
    }
    
    public static void commonMapTest() {
        for (int i = 0; i < 10; i++) {
            System.gc();
            Map<String, Byte[]> map = new HashMap<>();
            map.put(String.valueOf(i), new Byte[M_1 * 2]);
            // 手动GC
            System.gc();
        }
    }
}

Make sure that:

  • You have read the contribution guidelines.
  • You submit test cases (unit or integration tests) that back your changes.
  • Your local test passed ./mvnw clean install -Dmaven.javadoc.skip=true.

@codecov-commenter
Copy link

codecov-commenter commented Mar 16, 2023

Codecov Report

Merging #4486 (56ed9b2) into master (d764f9d) will decrease coverage by 0.28%.
The diff coverage is 15.00%.

@@             Coverage Diff              @@
##             master    #4486      +/-   ##
============================================
- Coverage     68.40%   68.13%   -0.28%     
+ Complexity     7591     7551      -40     
============================================
  Files          1027     1027              
  Lines         29246    29266      +20     
  Branches       2633     2635       +2     
============================================
- Hits          20006    19939      -67     
- Misses         7667     7751      +84     
- Partials       1573     1576       +3     
Impacted Files Coverage Δ
...g/apache/shenyu/common/cache/WindowTinyLFUMap.java 0.00% <0.00%> (ø)
...a/org/apache/shenyu/common/constant/Constants.java 66.66% <ø> (ø)
...pache/shenyu/plugin/base/AbstractShenyuPlugin.java 59.23% <0.00%> (-1.03%) ⬇️
...apache/shenyu/plugin/base/cache/MetaDataCache.java 0.00% <0.00%> (ø)
.../org/apache/shenyu/common/config/ShenyuConfig.java 68.39% <33.33%> (-0.51%) ⬇️
...pache/shenyu/plugin/base/cache/MatchDataCache.java 100.00% <100.00%> (ø)

... and 35 files with indirect coverage changes

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@yu199195 yu199195 merged commit 74c5022 into apache:master Mar 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[BUG] <may MemorySafeWindowTinyLFUMap cause a memory leak>
3 participants