Is there an (easy) way to determine what objects the GC is "removing"?

Jonathan Sylvester :

I have a Java program that creates a dozen arrays of of approximately 160 million in length each. The arrays contain primitives (char, short, and floats). In my algorithm, I've noticed (via jprofiler) that the GC runs a fair bit on my system (Windows VM machine on Google Cloud, 16 CPU cores, 64GB RAM) but I can't figure out why the GC is running so often and consuming 80% of total compute CPU power.

So I thought: If I could figure out (either through jvm commands/logs or preferably via a profiler just as jprofiler) what precise objects it was "garbage collecting", I could have a chance to understand what's going on and either fix a simple issue or rearchitect based on my better understanding of what Java is doing. (To the best of my knowledge, I have minimized object creations; I do use a lot of jdk8 parallel streaming features though, so I don't know if that is somehow causing GC issues.) Is there a way to determine which objects (or which object types) the GC is trying to garbage collect at any specific time so that I can better understand why the GC is running so often and so hard?

Ingo Kegel :

In JProfiler, you can use allocation recording for this purpose.

To show garbage collected objects in the "Recorded objects" view, change the liveness selector in the tool bar to either "Garbage collected objects" or "Live and garbage collected objects". The options dialog of the allocation call tree and allocation hot spot views has an equivalent drop-down.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=110282&siteId=1