JDK-8342849 : (bf) java/nio/Buffer/LimitDirectMemory.java fails with OutOfMemoryError
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.nio
  • Affected Version: 24
  • Priority: P3
  • Status: Closed
  • Resolution: Not an Issue
  • Submitted: 2024-10-22
  • Updated: 2024-12-02
  • Resolved: 2024-12-02
Related Reports
Relates :  
Relates :  
Sub Tasks
JDK-8342850 :  
JDK-8343234 :  
Description
Test: java/nio/Buffer/LimitDirectMemory.java

Exception in thread "main" java.lang.OutOfMemoryError: Cannot reserve 8192 bytes of direct buffer memory (allocated: 0, limit: 10)
at java.base/java.nio.Bits.reserveMemory(Bits.java:178)
at java.base/java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:105)
at java.base/java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:363)
at java.base/sun.nio.ch.Util.getTemporaryDirectBuffer(Util.java:242)
at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:304)
at java.base/sun.nio.ch.IOUtil.read(IOUtil.java:284)
at java.base/sun.nio.ch.FileChannelImpl.implRead(FileChannelImpl.java:251)
at java.base/sun.nio.ch.FileChannelImpl.read(FileChannelImpl.java:231)
at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:74)
at java.base/sun.nio.ch.ChannelInputStream.read(ChannelInputStream.java:103)
at java.base/java.io.InputStream.read(InputStream.java:220)
at java.base/java.util.Properties$LineReader.readLine(Properties.java:505)
at java.base/java.util.Properties.load0(Properties.java:421)
at java.base/java.util.Properties.load(Properties.java:410)

This test deliberately sets -XX:MaxDirectMemorySize=10 and this failure shows that the core libs code is now requiring at least 8K of direct memory buffers where previously it did not. 
Comments
This issue is irrelevant now that JDK-8344882 has been integrated.
27-11-2024

100 repeats of this test on each of the various x64 platforms succeeded.
29-10-2024