fixed a bug with direct ByteBuffer allocation