muyun12 opened a new pull request #7003:
URL: https://github.com/apache/skywalking/pull/7003


   ### Fix <bug description or the bug issue number or bug issue link>
   - [ ] Add a unit test to verify that the fix works.
   - [x] Explain briefly why the bug exists and how to fix it.
   
   fixed the issues #7001 
   
   In the following scene, it will cause a memory leak:
   ```java
        private static final ThreadPoolExecutor TPE = new ThreadPoolExecutor(4, 
4,60 , TimeUnit.SECONDS, new ArrayBlockingQueue<>(1000));
        public static void main(String[] args) {
                // do something
                TPE.execute(new Runnable() {
                        @Override
                        public void run() {
                                // do something
                        }
                });
                TPE.shutdown();
                try {
                        TPE.awaitTermination(2, TimeUnit.HOURS);
                } catch (InterruptedException e) {
                        // do something
                }
        }
   ```
   
   ThreadingMethodInterceptor class, as below:
   ```java
       @Override
       public void beforeMethod(final EnhancedInstance objInst, final Method 
method, final Object[] allArguments,
           final Class<?>[] argumentsTypes, final MethodInterceptResult result) 
{
           
           // this code cause a memory leak
           AbstractSpan span = 
ContextManager.createLocalSpan(generateOperationName(objInst, method));
           span.setComponent(ComponentsDefine.JDK_THREADING);
   
           final Object storedField = objInst.getSkyWalkingDynamicField();
           if (storedField != null) {
               final ContextSnapshot contextSnapshot = (ContextSnapshot) 
storedField;
               ContextManager.continued(contextSnapshot);
           }
   
       }
   ```
   
   
   


-- 
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.

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


Reply via email to