Search code examples
javamemory-managementdictionarymapdb

MapDB collection size issue


I'm using MapDB 0.9-snapshot. I have some collection containing several millions of records String->String. My problem is that the method size() on such ConcurrentMap(s) takes a lot of time and a lot of memory (I have even an OutOfMemory error).

Any other experienced such a problem? Thanks Bye


Solution

  • MapDB needs to traverse all entries in collections to count it. You may store count in external Atomic.Long and retrieve it separately, an example is here:

    https://github.com/jankotek/MapDB/blob/master/src/test/java/examples/Map_Size_Counter.java

    OOEM should not happen, it is probably due to GC overhead assertion.