jira-importer opened a new issue, #1289: URL: https://github.com/apache/httpcomponents-core/issues/1289
**[Ion Moldovan](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=herrmess)** opened **[HTTPCORE-513](https://issues.apache.org/jira/browse/HTTPCORE-513?redirect=false)** and commented Steps: 1. create a PHP page with the following content: 1. \<?php $response='abc'; echo str_pad($response, 2147483647); 1. send a request using jMeter to the said page Expected result: the request is received Actual result: the VM fails with: java.lang.OutOfMemoryError: Requested array size exceeds VM limit Dumping heap to java_pid20344.hprof ... Heap dump file created [3275879706 bytes in 7.490 secs] Uncaught Exception java.lang.OutOfMemoryError: Requested array size exceeds VM limit. See log file for details. Proposed solution: * rewrite org.apache.http.nio.util.ExpandableBuffer.expand() to: ```java /** * Expands buffer's capacity. */ protected void expand() { int newcapacity = (this.buffer.capacity() + 1) << 1; if (newcapacity < 0) { int headRoom = Integer.max(Long.BYTES, 8); // Reason: In GC the size of objects is passed as int (2 bytes). // Then, the header size of the objects is added to the size. // Long has the longest header available. Object header seems to be linked to it. // Details: I added a minimum of 8 just to be safe and because 8 is used in // java.lang.Object.ArrayList: private static final int MAX_ARRAY_SIZE = 2147483639. newcapacity = Integer.MAX_VALUE - headRoom; } expandCapacity(newcapacity); } ``` --- **Affects:** 4.4.9 **Remote Links:** - [GitHub Pull Request `#58` ](https://github.com/apache/httpcomponents-core/pull/58) **Backported to:** [4.4.10](https://github.com/apache/httpcomponents-core/milestone/47?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]
