[ping] Re: 8048192: (bf) Out of direct buffer memory message should include the limits

Brian Burkhalter brian.burkhalter at oracle.com
Thu Feb 21 21:09:11 UTC 2019


> On Feb 21, 2019, at 9:29 AM, Alan Bateman <Alan.Bateman at oracle.com> wrote:
> 
> On 21/02/2019 17:01, Brian Burkhalter wrote:
>> Ping
>> 
>> If we don’t want to improve the error message I suggest resolving this as “Won’t Fix."
> "MAX_MEMORY" or "TOTAL_CAPACITY" are the names of JDK internal fields so it might be better to leave those names out of the message. We ould be able to come up with shorter exception message to say that X bytes of direct memory cannot be allocated and have it include the current allocated and limit.

Here is an updated version:

@@ -172,8 +172,11 @@
             }
 
             // no luck
-            throw new OutOfMemoryError("Direct buffer memory");
-
+            throw new OutOfMemoryError
+                ("Cannot reserve "
+                 + size + " bytes of direct buffer memory (allocated: "
+                 + RESERVED_MEMORY.get() + ", limit: " + MAX_MEMORY +")");
+                
         } finally {

Example error:

bpb:CharBufferPutString{6}$ java -XX:MaxDirectMemorySize=42 -jar target/benchmarks.jar -f 1 -wi 5 -w 5 -i 5 -r 5
Error occurred during initialization of boot layer
java.lang.OutOfMemoryError: Cannot reserve 8192 bytes of direct buffer memory (allocated: 0, limit: 42)

Thanks,

Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/nio-dev/attachments/20190221/ee5be6e3/attachment.html>


More information about the nio-dev mailing list