gaozhangmin opened a new pull request #13939:
URL: https://github.com/apache/pulsar/pull/13939


   ### Motivation
   
   Cursors in 
`org.apache.bookkeeper.mledger.impl.ManagedLedgerImpl#waitingCursors` only be 
removed by `notifyCursors` when there were no new entries added, but cursors 
were added  every 10ms.
   ```
   ledger.getScheduledExecutor()
                           .schedule(() -> checkForNewEntries(op, callback, 
ctx),
                                   config.getNewEntriesCheckDelayInMillis(), 
TimeUnit.MILLISECONDS);
   ```
   This will cause memory leak, If there are  no new entry added. 
   
   ### Modifications
   1、Change ConcurrentLinkedQueue  waitingCursors to concurrentHashMap 
waitingCursorsMap, don't add cursors deduplicated.
   2、remove cursors in waitingCursors when `deactivateCursor`.
   
   
   If this fix is properly, I will add unit test afterly.
   ### Documentation
   
   Check the box below or label this PR directly (if you have committer 
privilege).
   
   Need to update docs? 
   
   - [ ] `doc-required` 
     
     (If you need help on updating docs, create a doc issue)
     
   - [ ] `no-need-doc` 
     
     (Please explain why)
     
   - [ ] `doc` 
     
     (If this PR contains doc changes)
   
   
   


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