Reputation: 21
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.
Upvotes: 0
Views: 528
Reputation: 533520
ByteBuffer.allocateDirect() is limited by the -XX:MaxDirectMemorySize
for HotSpot. When this limit is reach you get an OutOfMemoryError.
Upvotes: 2
Reputation: 1206
For both methods, the java.lang.OutOfMemoryError
is thrown when there is no virtual memory to spare.
Upvotes: 3