How can you monitor garbage collection in Java?

Your thoughts?

ArchanaK |

The HotSpot JVM comes with several "out of the box" tools that can be very useful. jstat and jconsole are two of these tools

jstat can be overwhelming and is more of a CLI approach to monitoring performance across the Java process you are running. You will need to know the process id and recommended that you use the -gc option to only get gc related information.

jconsole is more of a UI / visualization tool that allows you to see snap shots of memory, cpu, thread usage.

UdemyAlts |

jstat and jconsole will help you monitor performance of GC. with jstat i know you can see things like total cycles run, survivor space capacity and usage, eden space capacity and usage, old gen capacity and usage etc.

smilePanther007 |

i like can even manually trigger GC to see the impact it has on performance with regard to memory and cpu

blazingSaddles |

aren't there other tools out there not native to JVM that will help. i think some things can "ingest" information from jstat and make it more user friendly to look at.