jira-importer opened a new issue, #1514:
URL: https://github.com/apache/httpcomponents-core/issues/1514

   **[John 
Leacox](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=johnlcox)** 
opened 
**[HTTPCORE-726](https://issues.apache.org/jira/browse/HTTPCORE-726?redirect=false)**
 and commented
   
   Large responses can result in the `SharedInputBuffer` expanding unbounded, 
but with small intervals. Each expansion is the minimum 1024 byte aligned size 
bigger than the current buffer that is filling it beyond its current capacity. 
This leads to a ton of heap allocations and garbage collection each time is 
expands.
   
    
   
   It looks like the capacity updates to `CapacityChannel` are reporting 
current capacity rather than deltas/increments, so that even when small reads 
occur, the whole capacity is reported again to the channel and the capacity 
window also grows unbounded.
   
    
   
   I've attached a patch that includes some `println` statements for the 
capacity window size and for buffer being expanded along with the integration 
test `testLargeResponseConsumer` that shows the buffer and window growing quite 
large (the test passes, but the println statements show how large they are 
growing).
   
    
   
   For a fix I was thinking of updating the capacity tracking to be similar to 
`ReactiveDataConsumer` in tracking the number of bytes read and then reporting 
that delta to `CapacityChannel`. This does seem to prevent the buffer from 
expanding to huge sizes, but it still expands more than I would expect because 
after each read from the `SharedInputBuffer`. This remaining expansion appears 
to be from `CapacityWindow` always setting the IO sessions with `OP_READ` even 
when the window is still negative after the update.
   
   
   ---
   
   **Affects:** 5.1.3
   
   **Attachments:**
   - 
[SharedInputBuffer_Unbounded_Growth_Example.patch](https://issues.apache.org/jira/secure/attachment/13050917/SharedInputBuffer_Unbounded_Growth_Example.patch)
 (_5.78 kB_)
   - 
[SharedInputBuffer_Unbounded_Growth_Possible_Fix.patch](https://issues.apache.org/jira/secure/attachment/13050916/SharedInputBuffer_Unbounded_Growth_Possible_Fix.patch)
 (_3.31 kB_)
   
   **Backported to:** 
[5.1.5](https://github.com/apache/httpcomponents-core/milestone/77?closed=1)
   


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