Java - Heap vs Direct memory access
I recenty came across sun.misc.Unsafe class, allowing user to allocate,deallocate and in general access memory in a similar fashion like in C. I read in a couple of blogs that tackle this issue e.g. Which is faster - heap or direct memory - test results claim heap Off-heap memory vs DirectByteBuffer vs Heap - Off-heap seems to be fastest Memory mapped files for time series data - MappedByteBuffer faster than heap objects Article 1) seems to be in contradiction with the other ones and I fail to comprehend why. DirectMemoryBuffer is using sun.misc.Unsafe under the hood (so is MappedByteBuffer ),