[ 
https://issues.apache.org/jira/browse/RATIS-2414?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Tsz-wo Sze updated RATIS-2414:
------------------------------
        Parent: RATIS-1931
    Issue Type: Sub-task  (was: Improvement)

> Add leak detection for ZeroCopyMessageMarshaller
> ------------------------------------------------
>
>                 Key: RATIS-2414
>                 URL: https://issues.apache.org/jira/browse/RATIS-2414
>             Project: Ratis
>          Issue Type: Sub-task
>          Components: gRPC
>            Reporter: Shilun Fan
>            Assignee: Shilun Fan
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> *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