0

I wondering when there is no memory available does allocateDirect and allocate from ByteBuffer will return null pointer or sth else ? (I was unable to find it in java docs). Thanks in advance.

zawart
  • 21
  • 1

2 Answers2

3

For both methods, the java.lang.OutOfMemoryError is thrown when there is no virtual memory to spare.

nickolayratchev
  • 1,136
  • 1
  • 6
  • 15
2

ByteBuffer.allocateDirect() is limited by the -XX:MaxDirectMemorySize for HotSpot. When this limit is reach you get an OutOfMemoryError.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130