MemoryAllocator
HeapMemoryAllocator is used for onheap memory allocation, and UnsafeMemoryAllocator is used for off-heap memory allocation.
For offheap, allocate and free relies on OS to do the real management.
For onheap, Spark has to do the bookkeeping work to avoid gc.
Currenlty onheap is used by default. spark.memory.offHeap.enabled