Skip to content

Commit

Permalink
fixup! [FLINK-20663][core] Release unsafe memory instantly on segment…
Browse files Browse the repository at this point in the history
… freed.
  • Loading branch information
xintongsong committed Feb 15, 2021
1 parent ce98105 commit e4771ac
Showing 1 changed file with 13 additions and 0 deletions.
Expand Up @@ -22,6 +22,10 @@
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.concurrent.CompletableFuture;

import static org.junit.Assert.assertTrue;

/** Tests for the {@link HybridMemorySegment} in off-heap mode using unsafe memory. */
@RunWith(Parameterized.class)
public class HybridOffHeapUnsafeMemorySegmentTest extends MemorySegmentTestBase {
Expand All @@ -45,4 +49,13 @@ MemorySegment createSegment(int size, Object owner) {
public void testByteBufferWrapping() {
createSegment(10).wrap(1, 2);
}

@Test
public void testCallCleanerOnFree() {
final CompletableFuture<Void> cleanerFuture = new CompletableFuture<>();
MemorySegmentFactory.allocateOffHeapUnsafeMemory(
10, null, () -> cleanerFuture.complete(null))
.free();
assertTrue(cleanerFuture.isDone());
}
}

0 comments on commit e4771ac

Please sign in to comment.