title: What is the purpose to use direct memory in Java?
body: <blockquote>
    <p>Direct memory was introduced since java 1.4. The new I/O (NIO) classes introduced a new way of performing I/O based on channels and buffers. NIO added support for direct ByteBuffers, which can be passed directly to native memory rather than Java heap. Making them significantly faster in some scenarios because they can avoid copying data between Java heap and native heap.</p>
  </blockquote>
  
  <p>I never understand why do we use direct memory. Can someone help to give an example?</p>