jira-importer opened a new issue, #771: URL: https://github.com/apache/httpcomponents-core/issues/771
**[Steffen Pingel](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=spingel)** opened **[HTTPCORE-78](https://issues.apache.org/jira/browse/HTTPCORE-78?redirect=false)** and commented HttpCore allocates subtypes of ExpandleBuffer per connection for buffering requests and responses. ExpandleBuffer creates a buffer using ByteBuffer.allocateDirect() which is initialized to a certain size but may be resized as needed requiring the garbage collector to discard the old buffer. According to the documentation for ByteBuffer, direct buffers are recommended for "large, long-lived buffers that are subject to the underlying system's native I/O operations". It seems that these buffers are rather short-lived and ByteBuffer.allocate() might be a better choice for allocation. Another option would be to pass a factory for allocating and releasing buffers which could reduce the number of allocations by reusing buffers. --- **Affects:** 4.0-alpha4 **Attachments:** - [httpcore-bytebuffer-allocator.patch](https://issues.apache.org/jira/secure/attachment/12359114/httpcore-bytebuffer-allocator.patch) (_32.56 kB_) - [httpcore-bytebuffer-allocator.patch](https://issues.apache.org/jira/secure/attachment/12359105/httpcore-bytebuffer-allocator.patch) (_31.46 kB_) - [httpcore-heap-allocator.patch](https://issues.apache.org/jira/secure/attachment/12359219/httpcore-heap-allocator.patch) (_12.01 kB_) -- 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]
