Why the odd performance curve differential between ByteBuffer.allocate() and ByteBuffer.allocateDirect()

前端 未结 4 1222
醉酒成梦
醉酒成梦 2020-12-07 10:16

I\'m working on some SocketChannel-to-SocketChannel code which will do best with a direct byte buffer--long lived and large (tens to hundreds of me

4条回答
  •  [愿得一人]
    2020-12-07 10:30

    There are many reasons why this could happen. Without code and/or more details about the data, we can only guess what is happening.

    Some Guesses:

    • Maybe you hit the maximum bytes that can be read at a time, thus the IOwaits gets higher or memory consumption up without a decrease in loops.
    • Maybe you hit a critical memory limit, or the JVM is trying to free memory before a new allocation. Try playing around with the -Xmx and -Xms parameters
    • Maybe HotSpot can't/won't optimize, because the number of calls to some methods are too low.
    • Maybe there are OS or Hardware conditions that cause this kind of delay
    • Maybe the implementation of the JVM is just buggy ;-)

提交回复
热议问题