exception - Why am I getting a java.nio.BufferOverflowException -
i tried create simple program fun, i'm getting bufferoverflowexception:
bytebuffer bytebuffer = bytebuffer.allocatedirect(10); floatbuffer floatbuffer = bytebuffer.asfloatbuffer(); floatbuffer.put(new float[] {1, 0, 0});
what wrong?
when use bytebuffer.allocatedirect(10);
ask allocating 10 bytes of memory. putting 3 float
in buffer. each float uses 4 bytes of memory per official documentation. using 12 bytes , overflow.
to solve problem use 12 bytes instead of 10.
Comments
Post a Comment