Memory Fully utilized by Java ConcurrentHashMap (under Tomcat)

前端 未结 5 2012
执笔经年
执笔经年 2020-12-02 19:17

This is a memory stack (serves as a cache) that consist of nothing but a static ConcurrentHashMap (CHM).

All incoming HTTP request data are store in this Concurrent

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-02 20:02

    1) Does this looks like a Memory Leak?

    Yes, if the application keeps on putting objects in the map and never removes them, then that could very well be a memory leak.

    2) Each remove call remove(Object key, Object value) to remove a from CHM, does that removed object get GC?

    Objects can only be garbage collected if there is no live (running) thread that has a reference to them. The map is only one place where there's a reference to the object. There could still be other places that have references to the same object. But keeping the object in the map will prevent it from being garbage collected.

    3) Is this something to do with the GC settings?

    No; if an object is referenced, it cannot be garbage collected; it doesn't matter how you tweak the garbage collector.

提交回复
热议问题