From 6ecfb0f1de09a689a8775100e16a4c2d1a15509e Mon Sep 17 00:00:00 2001 From: CoolLoong <1542536763@qq.com> Date: Sun, 27 Aug 2023 16:57:06 +0800 Subject: [PATCH] fix: c++ memory release --- .../server/world/storage/rocksdb/RocksDBWorldStorage.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Allay-Server/src/main/java/cn/allay/server/world/storage/rocksdb/RocksDBWorldStorage.java b/Allay-Server/src/main/java/cn/allay/server/world/storage/rocksdb/RocksDBWorldStorage.java index 0f00b4354..c56a608ba 100644 --- a/Allay-Server/src/main/java/cn/allay/server/world/storage/rocksdb/RocksDBWorldStorage.java +++ b/Allay-Server/src/main/java/cn/allay/server/world/storage/rocksdb/RocksDBWorldStorage.java @@ -58,6 +58,7 @@ public RocksDBWorldStorage(Path path, Options options) throws WorldStorageExcept File logFolder = path.resolve("db/log").toFile(); if (!logFolder.exists()) logFolder.mkdirs(); db = RocksDB.open(options, dbFolder.getAbsolutePath()); + options.close(); } catch (RocksDBException e) { throw new WorldStorageException(e); } @@ -110,7 +111,9 @@ public CompletableFuture writeChunk(Chunk chunk) throws WorldStorageExcept } } ); - this.db.write(new WriteOptions(), writeBatch); + try (WriteOptions writeOptions = new WriteOptions()) { + this.db.write(writeOptions, writeBatch); + } return null; } catch (RocksDBException e) { throw new RuntimeException(e);