Shilun Fan created RATIS-2414:
---------------------------------

             Summary: Add leak detection for ZeroCopyMessageMarshaller
                 Key: RATIS-2414
                 URL: https://issues.apache.org/jira/browse/RATIS-2414
             Project: Ratis
          Issue Type: Improvement
          Components: gRPC
            Reporter: Shilun Fan
            Assignee: Shilun Fan


## Problem

The current ZeroCopyMessageMarshaller lacks safeguards to detect and handle 
resource leaks. When InputStream instances are not properly released (via 
`release()` method), it can lead to native memory leaks in production, 
especially in high-throughput scenarios where gRPC zero-copy optimization is 
used with Netty ByteBuf.
 
## Solution

Add leak detection and cleanup capabilities to ZeroCopyMessageMarshaller:
 
- Add `getUnclosedCount()`: Returns the number of unclosed streams for 
monitoring
- Add `checkLeaks(String context)`: Throws IllegalStateException if unclosed 
streams exist, used for test assertions
- Add `close()`: Cleanup method that closes all unclosed streams with logging, 
providing last-resort protection



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to