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?