title: Can you get basic GC stats in Java?
body: <p>I would like to have some long-running server applications periodically output general GC performance numbers in Java, something like the GC equivalent of Runtime.freeMemory(), etc.  Something like number of cycles done, average time, etc.</p>
  
  <p>We have systems running on customer machines where there is a suspicion that misconfigured memory pools are causing excessive GC frequency and length - it occurs to me that it would be good in general to periodically report the basic GC activity.</p>
  
  <p>Is there any platform independent way to do this?</p>
  
  <p><strong>EDIT: I specifically want to output this data to the system log (the console), while running; this is not something I want to connect to the JVM for, as would be with JConsole or JVisualVM.</strong></p>
  
  <p>Edit2: The MX bean looks like what I want - does anyone have a working code example which obtains one of these?</p>