zawart
zawart

Reputation: 21

ByteBuffer allocate and allocateDirect

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

Answers (2)

Peter Lawrey
Peter Lawrey

Reputation: 533520

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

Upvotes: 2

nickolayratchev
nickolayratchev

Reputation: 1206

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

Upvotes: 3

Related Questions