Finding Java memory leak when not all used heap is reachable from threads

后端 未结 5 855
醉话见心
醉话见心 2021-02-18 15:52

I am looking into a potential memory leak (or at least memory waste) in a largish Java based system. The JVM is running with a maximum heap size of 5 GB and 2-3GB heap usage is

5条回答
  •  醉话见心
    2021-02-18 16:51

    I too faced the problem with memory leaks at our site,
    Use yourkit java profiler which provide lots of information and with its ability you can have a wider image where all the memory is being utilized.
    You can find a great tutorial Find Java Memory Leaks with the above tool.

    Your question,

    "What kind of Objects are there that are not reachable from an instance of java.lang.Thread other then Objects in the Finalizer Queue and unreferenced objects pending GC?"

    There are four kinds of object,

    1. Strong reachable, objects that can be reached directly via references from live objects
    2. Weak/Soft reachable, objects that are having weak/Soft reference associated with them
    3. Pending Finalization, objects that are pending for finalization and whose reference can be reached through finalizer queue
    4. Unreachable these are objects that are unreachable from GC roots, but not yet collected

    Besides these JVM also uses Native memory whose information you can find on IBM Heap and native memory use by the JVM and Thanks for the memory and according to YourKit the JVM Memory Structure has Non-Heap Memory whose definition according to them is

    Also, the JVM has memory other than the heap, referred to as non-heap memory. It is created at the JVM startup and stores per-class structures such as runtime constant pool, field and method data, and the code for methods and constructors, as well as interned Strings.

提交回复
热议问题