yhzdys opened a new pull request, #700:
URL: https://github.com/apache/httpcomponents-core/pull/700

   ## Summary
   
   `BasicAsyncEntityProducer.produce` writes the entire content buffer in a 
single `DataStreamChannel.write` call.
   When a heap `ByteBuffer` is written to the socket, the JDK copies it through 
a temporary direct buffer sized to the buffer's `remaining()`.
   These buffers are cached per I/O dispatcher thread and never released,
   so a large entity pins an equally large amount of native memory per thread — 
invisible to GC, not bounded by `-Xmx`,
   and able to trigger `OutOfMemoryError: Direct buffer memory` under 
concurrent large transfers.
   
   ## Change
   
   Chunk output to 16 KiB per `produce` round (temporarily narrowing the buffer 
`limit`, restored in `finally`).
   Remaining bytes are written by subsequent `produce` calls, which both 
transports guarantee while `available() > 0`.
   16 KiB matches the default HTTP/2 max frame size and the JDK HTTP client 
buffer size.
   Regression tests cover multi-chunk and partial write scenarios.
   


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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to