开发者

java memcopy DirectBuffer

Hi I am working with direct buffers in Java, and I need to have a fast memcopy on them. In C there is the memcpy command, and on Java Arrays I have Arrays.copyOf. But there is no way of using Arrays instead of direct buffers, because I need to transfer those 开发者_运维知识库to OpenGL.


If you mean "direct" ByteBuffers, there's a put method which accepts other ByteBuffer instances so you can copy around.


You can just use put() with either a byte[] or a ByteBuffer, this will use a native call memcpy under neither in the Sun/Oracle JDK.

For direct and heap byte buffers put() uses the Bits.copyFromArray() and Unsafe.copyMemory() methods.


check System.arrayCopy it's the fastest way to copy part of an array in java

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜