To `allocate()` or to `allocateDirect()`, that is the question.
For some years now I've just stuck to the thought that since `DirectByteBuffer`s are a direct memory mapping at OS level, that it would perform quicker with get/put calls than `HeapByteBuffer`s. I never was really interested in finding out the exact details regarding the situation until now. I want to know which of the two types of `ByteBuffer`s are faster and on what conditions. To give a specific answer, you need to say specificly what you are doing with them. If one was always faster than the other, why would there be two variants. Perhaps you can expand on why you are now "really interested in finding out the exact details" BTW: Have you read the code, esp for DirectByteBuffer?
以上就是ByteBuffer.allocate() vs. ByteBuffer.allocateDirect()的详细内容，更多请关注web前端其它相关文章！