Skip to content

Commit 017b2dc

Browse files
committed
Remove BytesToBytesMap.finalize()
This is no longer necessary now that we do leak detection and cleanup at higher levels (as part of MemoryManager).
1 parent 50e9671 commit 017b2dc

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

unsafe/src/main/java/org/apache/spark/unsafe/map/BytesToBytesMap.java

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -157,16 +157,6 @@ public BytesToBytesMap(
157157
this(memoryManager, initialCapacity, 0.70, enablePerfMetrics);
158158
}
159159

160-
@Override
161-
protected void finalize() throws Throwable {
162-
try {
163-
// In case the programmer forgot to call `free()`, try to perform that cleanup now:
164-
free();
165-
} finally {
166-
super.finalize();
167-
}
168-
}
169-
170160
/**
171161
* Returns the number of keys defined in the map.
172162
*/

unsafe/src/test/java/org/apache/spark/unsafe/map/AbstractBytesToBytesMapSuite.java

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,11 +95,15 @@ private static boolean arrayEquals(
9595
@Test
9696
public void emptyMap() {
9797
BytesToBytesMap map = new BytesToBytesMap(memoryManager, 64);
98-
Assert.assertEquals(0, map.size());
99-
final int keyLengthInWords = 10;
100-
final int keyLengthInBytes = keyLengthInWords * 8;
101-
final byte[] key = getRandomByteArray(keyLengthInWords);
102-
Assert.assertFalse(map.lookup(key, BYTE_ARRAY_OFFSET, keyLengthInBytes).isDefined());
98+
try {
99+
Assert.assertEquals(0, map.size());
100+
final int keyLengthInWords = 10;
101+
final int keyLengthInBytes = keyLengthInWords * 8;
102+
final byte[] key = getRandomByteArray(keyLengthInWords);
103+
Assert.assertFalse(map.lookup(key, BYTE_ARRAY_OFFSET, keyLengthInBytes).isDefined());
104+
} finally {
105+
map.free();
106+
}
103107
}
104108

105109
@Test

0 commit comments

Comments
 (0)