xuyicheng1995 opened a new issue, #4475:
URL: https://github.com/apache/shenyu/issues/4475

   ### Is there an existing issue for this?
   
   - [X] I have searched the existing issues
   
   ### Current Behavior
   
   when i use System.gc(), no memory leaked
   
   ### Expected Behavior
   
   memory leaked
   
   ### Steps To Reproduce
   
   public class TestMemoryLeak {
       // 1m内存
       private static final int M_1 = 1 * 1024 * 1024;
   
       public static void main(String[] args) throws InterruptedException, 
IOException {
           System.in.read();
           try {
               mswtMapTest();
           } catch (Exception e) {
               e.printStackTrace();
           }
           System.gc();
           TimeUnit.SECONDS.sleep(Long.MAX_VALUE);
       }
   
       public static void mswtMapTest() {
           for (int i = 0; i < 10; i++) {
               System.gc();
               MemorySafeWindowTinyLFUMap<String, Byte[]> map = new 
MemorySafeWindowTinyLFUMap<>(1, 100);
               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();
           }
       }
   }
   
   ### Environment
   
   ```markdown
   ShenYu version(s):
   ```
   
   
   ### Debug logs
   
   Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
        at 
org.apache.shenyu.common.cache.TestMemoryLeak.mswtMapTest(TestMemoryLeak.java:44)
        at 
org.apache.shenyu.common.cache.TestMemoryLeak.main(TestMemoryLeak.java:32)
   
   ### Anything else?
   
   MemorySafeWindowTinyLFUMap  hold a static reference ALL, every reference of 
MemorySafeWindowTinyLFUMap will be always hold by the reference, and may cause 
a memory leak


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to