0

Can anyone tell me what is the usage of mapdb.compact() method.I am looking for how to clear the objects from heap after calling commit() method

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216
Shig
  • 11
  • 1

1 Answers1

0

Generally speaking, the purpose of the compact() method is to reduce resource usage compaction the store's data structures. The "Getting Started" section of the manual says:

MapDB needs compaction sometimes. Run DB.compact() or see background compaction options.

However:

  • The precise behavior of compaction will depend on the kind of MapDB you use. In some cases, it is not (yet) implemented. (You don't say what kind you are using ...)

  • It is probably inadvisable (inefficient) to compact frequently.

  • My guess is that compacting a MapDB that stores the data in the Java heap will not immediately free the memory. Rather, it will make objects unreachable so that they can be reclaimed by the Java GC.

Stephen C
  • 698,415
  • 94
  • 811
  • 1,216