Just wondering if the system pre-allocate any space for empty guava cache? I am new to guava cache, can someone help me to understand this problem?
Also I test it with code below:
long preMemUsage = Runtime.getRuntime().totalMemory() -Runtime.getRuntime().freeMemory();
Cache<String, CountObject> cache = CacheBuilder.newBuilder()
.maximumSize(12000)
.expireAfterAccess(7200,TimeUnit.SECONDS)
.concurrencyLevel(10)
.recordStats().build();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
}
long postMemUsage = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
System.out.println("Before: " + preMemUsage);
System.out.println("After: " + postMemUsage);
The weird thing is the used memory is decreased after..... no idea why. Can someone explain this.
Thanks a lot : )