Skip to content

Commit

Permalink
[SPARK-10399][SPARK-23879][FOLLOWUP][CORE] Free unused off-heap memor…
Browse files Browse the repository at this point in the history
…y in MemoryBlockSuite

## What changes were proposed in this pull request?

As viirya pointed out [here](#19222 (comment)), this PR explicitly frees unused off-heap memory in `MemoryBlockSuite`

## How was this patch tested?

Existing UTs

Author: Kazuaki Ishizaki <ishizaki@jp.ibm.com>

Closes #21117 from kiszk/SPARK-10399-free-offheap.
  • Loading branch information
kiszk authored and cloud-fan committed Apr 23, 2018
1 parent c48085a commit c3a86fa
Showing 1 changed file with 4 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@ private void check(MemoryBlock memory, Object obj, long offset, int length) {
} catch (Exception expected) {
Assert.assertThat(expected.getMessage(), containsString("should not be larger than"));
}

memory.setPageNumber(MemoryBlock.NO_PAGE_NUMBER);
}

@Test
Expand Down Expand Up @@ -165,11 +167,13 @@ public void testOffHeapArrayMemoryBlock() {
int length = 56;

check(memory, obj, offset, length);
memoryAllocator.free(memory);

long address = Platform.allocateMemory(112);
memory = new OffHeapMemoryBlock(address, length);
obj = memory.getBaseObject();
offset = memory.getBaseOffset();
check(memory, obj, offset, length);
Platform.freeMemory(address);
}
}

0 comments on commit c3a86fa

Please sign in to comment.