Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
谁能告诉我 mapdb.compact() 方法的用途是什么。我正在寻找如何在调用 commit() 方法后从堆中清除对象
一般来说,该compact()方法的目的是减少资源使用压缩存储的数据结构。手册的“入门”部分说:
compact()
MapDB有时需要压实。运行DB.compact()或查看后台压缩选项。
MapDB
DB.compact()
然而:
压缩的精确行为取决于您使用的 MapDB 类型。在某些情况下,它(尚未)实施。(你不说你用的是什么类型的......)
经常压缩可能是不可取的(低效的)。
我的猜测是压缩将数据存储在 Java 堆中的 MapDB 不会立即释放内存。相反,它将使对象无法访问,以便它们可以被 Java GC 回收。