Github user cloud-fan commented on a diff in the pull request:
https://github.com/apache/spark/pull/19222#discussion_r175604062
--- Diff:
common/unsafe/src/main/java/org/apache/spark/unsafe/memory/HeapMemoryAllocator.java
---
@@ -94,12 +95,12 @@ public void free(MemoryBlock memory) {
}
// Mark the page as freed (so we can detect double-frees).
- memory.pageNumber = MemoryBlock.FREED_IN_ALLOCATOR_PAGE_NUMBER;
+ memory.setPageNumber(MemoryBlock.FREED_IN_ALLOCATOR_PAGE_NUMBER);
// As an additional layer of defense against use-after-free bugs, we
mutate the
// MemoryBlock to null out its reference to the long[] array.
- long[] array = (long[]) memory.obj;
- memory.setObjAndOffset(null, 0);
+ long[] array = ((OnHeapMemoryBlock)memory).getLongArray();
+ memory.resetObjAndOffset();
long alignedSize = ((size + 7) / 8) * 8;
if (shouldPool(alignedSize)) {
--- End diff --
I think in the future we should cache `MemoryBlock` directly, so that we
can have a unified pool for both on-heap and off-heap memory manager.
---
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]