1

I'm evaluating MapDB for an application. I create the DB following way.

DB db = DBMaker.fileDB(new File("mapdbtest1")).cacheHashTableEnable()
                .cacheSize(50000).closeOnJvmShutdown()
                .encryptionEnable("password").make();

After putting 50000 objects in the DB and then calling GC explicitly, the used size is too less and looks like the objects are not in memory cache any more. I was expecting the cacheSize no. of objects to be always in memory, irrespective of GC or OOM and rest of them be swapped.

=======================
Memory : after committing to DB
free memory: 1426 MB
allocated memory: 2860 MB
used memory: 1433 MB
max memory: 3641 MB
total free memory: 2207 MB
=======================
=======================
Memory : after gc
free memory: 2479 MB
allocated memory: 2494 MB
used memory: 14 MB
max memory: 3641 MB
total free memory: 3626 MB
=======================

Is my understanding wrong ?

TechCrunch
  • 2,924
  • 5
  • 45
  • 79
  • The stats do not make sense. The second uses way more memory and... has more free memory. – Dici Sep 11 '15 at 18:19
  • @Dici I did not understand what you are saying. – TechCrunch Sep 11 '15 at 18:21
  • The stats you included in your question are inconsistent. If you have more free memory, you should have less used memory... look at your stats after GC and conclude – Dici Sep 11 '15 at 18:34
  • @Dici, they look okay to me. I've only 14MB of used memory after GC. – TechCrunch Sep 11 '15 at 19:16
  • Oh so the commas are for separating thousands ? That was not clear... – Dici Sep 11 '15 at 19:19
  • @Dici, my bad - the number formatter printed it that way. – TechCrunch Sep 11 '15 at 19:21
  • There must be a doc for this, but I think it is well possible that the cached objects have a limited retention. If you never look them up or use them, they will be expired. This is just an idea, I have not read any doc and do not know this class – Dici Sep 11 '15 at 19:25
  • @Didi, I did read the documentation at http://www.mapdb.org/_downloads/mapdb-manual.pdf. I did not specify expiration time. So they are bound to live forever. Also, the manual doesn't specify GC eating up HashTable cache. – TechCrunch Sep 11 '15 at 19:27
  • `Old entries are evicted by hash collisions`. It means some of the objects you put on the cache have been overwritten by objects with the same hashcode inserted later in the cache. Can you know the number of objects in your cache ? If the API does not allow you to do that, you can use something like JProfiler – Dici Sep 12 '15 at 07:58
  • I put 50000 entries in Cache. All the entries have different string keys, but same object value. – TechCrunch Sep 14 '15 at 03:48
  • And yet you can have collisions between the keys since their hash code is going to be computed modulo `cacheSize`... – Dici Sep 14 '15 at 08:49

0 Answers0