Eclipse :: Enable Verbose Garbage Collection

Verbose options instructs the underlying JVM to print relevant information (as per our needs) on the output console. The information provided by these options is used for debugging purposes. Hence it would not be advisable to enable these options on production environments.

These three verbose options are as follows :-

-verbose:class is used to display the information about classes being loaded by JVM. This is useful when using class loaders for loading classes dynamically or for analysing what all classes are getting loaded in a particular scenario.

-verbose:gc is used to check garbage collection event information. When used as command line argument for running Java program, the details of garbage collection are printed on the console.

-verbose:jni is used for printing the native methods as and when they are registered in the application. These methods include JDK as well as custom native methods. Note that jni stands for Java Native Interface.

These can be enabled in the following ways:

  • Command Line (while executing JAVA program)
  • Enable Eclipse to start Verbose options on startup
  • Enable verbose options per JAVA project in Eclipse

Lets configure Eclipse verbose options for a single JAVA project.

  • Click on RUN menu in Eclispe --> Run Configurations
  • Select the appropriate project via browse button (Main Tab)
  • Click on Arguments Tab & enter relevant verbose option (e.g. -verbose:gc as shown below)
  • Click Apply and run your JAVA project.

Did you find this article valuable?

Support Manish Warang by becoming a sponsor. Any amount is appreciated!