jankotek / mapdb

MapDB provides concurrent Maps, Sets and Queues backed by disk storage or off-heap-memory. It is a fast and easy to use embedded Java database engine.
https://mapdb.org
Apache License 2.0
4.89k stars 873 forks source link

tempFile is not deleted after close #973

Open CreeTar opened 4 years ago

CreeTar commented 4 years ago

Hi, i'm experimenting with mapdb-3.0.8 and tried tempFileDB() but one problem is that the file is created with a timestamp, therefore the file.delete() that is executed right after, won't clean up previous tempFiles. And then the deleteOnExit() has no effect, because the file is still in use, even after calling db.close().

My snippet:

def db = DBMaker
  .tempFileDB()
  .fileMmapEnable()
  .make()
addShutdownHook {
  db.close()
}

I also tried to use closeOnJvmShutdownWeakReference and closeOnJvmShutdown instead of the groovy addShutdownHook to no avail. And fileDeleteAfterClose in combination with fileDB.

Any tip what might be the problem, why the datafile is still locked for changes? I can deleted it manually though, but a new File(...).delete() will return false

-- Windows 10, Groovy 2.5.4

LEIHAOYUAN commented 1 year ago

I had the same problem

tianyawenke commented 8 months ago

Me too