Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想知道当没有可用内存时, allocateDirect 和从 ByteBuffer 分配会返回空指针还是其他?(我无法在 java 文档中找到它)。提前致谢。
对于这两种方法,java.lang.OutOfMemoryError当没有可用的虚拟内存时抛出 。
java.lang.OutOfMemoryError
ByteBuffer.allocateDirect() 受-XX:MaxDirectMemorySizeHotSpot 的限制。当达到此限制时,您会收到 OutOfMemoryError。
-XX:MaxDirectMemorySize