TOO many live object in memory!

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

TOO many live object in memory!

markone
when I use 'jmap -histo:live <pid>' to analyze ratpack server process, I found:

 1:       2235770       71544640  java.util.concurrent.ConcurrentHashMap$Node
   2:          5315       70913136  [B
   3:       1735936       41662464  ratpack.registry.PredicateCacheability$CacheKey
   4:       1044934       33437888  com.google.common.collect.RegularImmutableList
   5:        284894       30205568  [Ljava.util.concurrent.ConcurrentHashMap$Node;
   6:        427399       27353536  java.util.concurrent.ConcurrentHashMap
   7:       1049572       25399592  [Ljava.lang.Object;
   8:       1044915       25077960  com.google.common.collect.Iterables$2
   9:        706560       16957440  io.netty.buffer.PoolThreadCache$MemoryRegionCache$Entry
  10:        627059       15049416  com.google.common.reflect.TypeToken$SimpleTypeToken

There is too many PredicateCacheability.CacheKey objects lived in memory.

I tracked my code, and found:
private <T> Iterable<? extends T> getFromPredicateCache(TypeToken<T> type, Predicate<? super T> predicate) {
    return Types.cast(compute(predicateCache, new PredicateCacheability.CacheKey<>(type, predicate), k -> delegate.all(type, predicate)));
  }
This line will create PredicateCacheability.CacheKey object, and put it into a ConcurrentMap. It will keep alive.

How can this happen?

There is a possibility, I use context object to pass down some object, such as:
context.next(just(ContextParams.class, contextParams));
for using in next handler. Is this right?
Reply | Threaded
Open this post in threaded view
|

Re: TOO many live object in memory!

markone
I found the problem
when I put a ContextParams instance into context(use:  context.next(just(ContextParams.class, contextParams)))

the live object of ContextParams class increment by 1, and it never drop down.
See the jmap -histo:live result:

[[email protected] bin]# jmap -histo:live 24292 | grep ContextParams
 738:             6             96  com.waqu.common.mvc.filter.ContextParams
[[email protected] bin]# jmap -histo:live 24292 | grep ContextParams
 700:             7            112  com.waqu.common.mvc.filter.ContextParams
[[email protected] bin]# jmap -histo:live 24292 | grep ContextParams
 664:             8            128  com.waqu.common.mvc.filter.ContextParams
Reply | Threaded
Open this post in threaded view
|

Re: TOO many live object in memory!

Luke Daley
Administrator
We've removed this caching layer in 0.9.15.
Reply | Threaded
Open this post in threaded view
|

Re: TOO many live object in memory!

markone
Thanks´╝î I'll try version 0.9.15