java.lang.OutOfMemoryError: Direct buffer memory

JDK Bug System | Webbug Group | 1 year ago
  1. 0

    FULL PRODUCT VERSION : java version "1.8.0_60" Java(TM) SE Runtime Environment (build 1.8.0_60-b27) Java HotSpot(TM) 64-Bit Server VM (build 25.60-b23, mixed mode) ADDITIONAL OS VERSION INFORMATION : Linux localhost 2.6.32-5-amd64 #1 SMP Thu Mar 22 17:26:33 UTC 2012 x86_64 GNU/Linux A DESCRIPTION OF THE PROBLEM : Our system with a WebApp + Backend architecture, both running on separate hosts in JVMs connected via our proprietary TCP based protocol using java.nio is running into java.lang.OutOfMemoryError: Direct buffer memory on the WebApp server originating by call stack at our java.nio usage. As our protocol is using small direct buffers, a test was done with the following simple code: import java.nio.ByteBuffer; public class TestDirectBuffer { public static void main( String args[] ) throws Exception { while(true) { ByteBuffer.allocateDirect(522); } } } When run as follows, a java.lang.OutOfMemoryError: Direct buffer memory is thrown after a few seconds: java -Xmx200m -Xms200m -XX:+DisableExplicitGC -XX:MaxDirectMemorySize=512m -XX:+UseConcMarkSweepGC -XX:+UseCompressedOops TestDirectBuffer Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory at java.nio.Bits.reserveMemory(Bits.java:658) at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) at TestDirectBuffer.main(TestDirectBuffer.java:8) Without -XX:+DisableExplicitGC it keeps up continuously without errors and without any leaks into memory, using constantly about 3 GByte virtual memory: java -Xmx200m -Xms200m -XX:MaxDirectMemorySize=512m -XX:+UseConcMarkSweepGC -XX:+UseCompressedOops TestDirectBuffer same result in 1.7.0_80, 1.8.0_05, 1.8.0_60 and many more STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : use above test code with JVM flag DisableExplicitGC set EXPECTED VERSUS ACTUAL BEHAVIOR : EXPECTED - no memory leak ACTUAL - direct buffer memory is filled until JVM exits with java.lang.OutOfMemoryError: Direct buffer memory ERROR MESSAGES/STACK TRACES THAT OCCUR : Exception in thread "main" java.lang.OutOfMemoryError: Direct buffer memory at java.nio.Bits.reserveMemory(Bits.java:658) at java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123) at java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311) at TestDirectBuffer.main(TestDirectBuffer.java:8) REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- // java -Xmx200m -Xms200m -XX:+DisableExplicitGC -XX:MaxDirectMemorySize=512m -XX:+UseConcMarkSweepGC -XX:+UseCompressedOops TestDirectBuffer // runs fine without -XX:+DisableExplicitGC import java.nio.ByteBuffer; public class TestDirectBuffer { public static void main( String args[] ) throws Exception { while(true) { ByteBuffer.allocateDirect(522); } } } ---------- END SOURCE ---------- CUSTOMER SUBMITTED WORKAROUND : don't use -XX:+DisableExplicitGC

    JDK Bug System | 1 year ago | Webbug Group
    java.lang.OutOfMemoryError: Direct buffer memory
  2. 0

    OutOfMemory: Direct buffer memory

    GitHub | 2 years ago | defabricated
    io.netty.handler.codec.DecoderException: java.lang.OutOfMemoryError: Direct buffer memory
  3. Speed up your debug routine!

    Automated exception search integrated into your IDE

  4. 0

    sshandle still have memory leak, tested with 4.0.24, 4.0.25 and 4.0.17.

    GitHub | 2 years ago | devsunny
    java.lang.OutOfMemoryError: Direct buffer memory
  5. 0

    OutOfMemoryError: Direct buffer memory

    GitHub | 2 years ago | kegangkai
    java.lang.OutOfMemoryError: Direct buffer memory

    7 unregistered visitors
    Not finding the right solution?
    Take a tour to get the most out of Samebug.

    Tired of useless tips?

    Automated exception search integrated into your IDE

    Root Cause Analysis

    1. java.lang.OutOfMemoryError

      Direct buffer memory

      at java.nio.Bits.reserveMemory()
    2. Java RT
      ByteBuffer.allocateDirect
      1. java.nio.Bits.reserveMemory(Bits.java:658)
      2. java.nio.DirectByteBuffer.<init>(DirectByteBuffer.java:123)
      3. java.nio.ByteBuffer.allocateDirect(ByteBuffer.java:311)
      3 frames
    3. Unknown
      TestDirectBuffer.main
      1. TestDirectBuffer.main(TestDirectBuffer.java:8)
      1 frame