java 内存复制 DirectBuffer
您好,我正在使用 Java 中的直接缓冲区,并且我需要对它们进行快速内存复制。在 C 中,有 memcpy 命令,在 Java 数组中,有 Arrays.copyOf。但是没有办法使用数组代替直接缓冲区,因为我需要将它们传输到 OpenGL。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果您的意思是“直接”ByteBuffer,则有一个 put 方法接受其他 ByteBuffer 实例,以便您可以复制。
If you mean "direct" ByteBuffers, there's a put method which accepts other
ByteBuffer
instances so you can copy around.您可以仅将
put()
与 byte[] 或 ByteBuffer 一起使用,这将在 Sun/Oracle JDK 中使用本机调用 memcpy。对于直接和堆字节缓冲区,
put()
使用Bits.copyFromArray()
和Unsafe.copyMemory()
方法。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 theBits.copyFromArray()
andUnsafe.copyMemory()
methods.检查 System.arrayCopy 这是在java中复制部分数组的最快方法
check System.arrayCopy it's the fastest way to copy part of an array in java