Skip to content

Commit

Permalink
Remove BytesToBytesMap.finalize()
Browse files Browse the repository at this point in the history
This is no longer necessary now that we do leak
detection and cleanup at higher levels (as part of MemoryManager).
  • Loading branch information
JoshRosen committed Apr 29, 2015
1 parent 50e9671 commit 017b2dc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
Expand Up @@ -157,16 +157,6 @@ public BytesToBytesMap(
this(memoryManager, initialCapacity, 0.70, enablePerfMetrics);
}

@Override
protected void finalize() throws Throwable {
try {
// In case the programmer forgot to call `free()`, try to perform that cleanup now:
free();
} finally {
super.finalize();
}
}

/**
* Returns the number of keys defined in the map.
*/
Expand Down
Expand Up @@ -95,11 +95,15 @@ private static boolean arrayEquals(
@Test
public void emptyMap() {
BytesToBytesMap map = new BytesToBytesMap(memoryManager, 64);
Assert.assertEquals(0, map.size());
final int keyLengthInWords = 10;
final int keyLengthInBytes = keyLengthInWords * 8;
final byte[] key = getRandomByteArray(keyLengthInWords);
Assert.assertFalse(map.lookup(key, BYTE_ARRAY_OFFSET, keyLengthInBytes).isDefined());
try {
Assert.assertEquals(0, map.size());
final int keyLengthInWords = 10;
final int keyLengthInBytes = keyLengthInWords * 8;
final byte[] key = getRandomByteArray(keyLengthInWords);
Assert.assertFalse(map.lookup(key, BYTE_ARRAY_OFFSET, keyLengthInBytes).isDefined());
} finally {
map.free();
}
}

@Test
Expand Down

0 comments on commit 017b2dc

Please sign in to comment.