java - Guava cache memory leak -


i using guava library 14.0.1 implement caching service (a web application containing servlet put , values). web application deployed on machine containing 1gb ram (google backend). number of write , read operations huge (50 queries per second).

the amount of ram used on machine keeps on increasing after hitting maximumsize limit. suspect memory leak.

following code using create cache

cache cache = cachebuilder.newbuilder()                 .expireafterwrite(1, timeunit.days)                 .initialcapacity(2000000)                 .maximumsize(3800000)                 .concurrencylevel(50)                 .recordstats()                 .build(); 

retrieving values using

map result = cache.getallpresent(keys); 

putting values in cache using

cache.put(key, value); 

is there setting can use stop increase in ram usage beyond limit.

the query rate pretty low, try reducing concurrency (possibly 1-4) , reducing maximum size. given limited resources of machine, suspect maximum size of 1k 100k more appropriate depending on how large objects are.

from java docs

public cachebuilder maximumsize(long size) specifies maximum number of entries cache may contain.

if entries 1 kb, need 4 gb cache alone.

the reason rate pretty low call collection should typically take micro-second (i.e. limit in order of 1 million per second, concurrency of 1)


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -