提交 a01b5925 编写于 作者: F fyrz

[RocksJava] DefaultColumnFamily Memory Fix

In the current implementation DefaultColumnFamily will not disown
the native handle. As the database handles the lease on the native
handle this should be the case.
上级 22c73d15
......@@ -1270,7 +1270,10 @@ public class RocksDB extends RocksObject {
* @return The handle of the default column family
*/
public ColumnFamilyHandle getDefaultColumnFamily() {
return new ColumnFamilyHandle(this, getDefaultColumnFamily(nativeHandle_));
ColumnFamilyHandle cfHandle = new ColumnFamilyHandle(this,
getDefaultColumnFamily(nativeHandle_));
cfHandle.disOwnNativeHandle();
return cfHandle;
}
/**
......
......@@ -58,11 +58,7 @@ public class ColumnFamilyTest {
Options options = null;
ColumnFamilyHandle cfh = null;
try {
options = new Options();
options.setCreateIfMissing(true);
DBOptions dbOptions = new DBOptions();
dbOptions.setCreateIfMissing(true);
options = new Options().setCreateIfMissing(true);
db = RocksDB.open(options, dbFolder.getRoot().getAbsolutePath());
cfh = db.getDefaultColumnFamily();
......@@ -78,9 +74,6 @@ public class ColumnFamilyTest {
assertThat(cfh).isNotNull();
assertThat(actualValue).isEqualTo(value);
} finally {
if (cfh != null) {
cfh.dispose();
}
if (db != null) {
db.close();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册