Class GCToolKit


  • public class GCToolKit
    extends Object
    The primary API for analyzing Java Garbage Collection (GC) logs.
    • Constructor Detail

      • GCToolKit

        public GCToolKit()
        Instantiate a GCToolKit object. The same GCToolKit object can be used to analyze more than one GC log. It is not necessary to create a GCToolKit object for each GC log to be analyzed. Please note, however, that GCToolKit API is not thread safe.
    • Method Detail

      • LOG_DEBUG_MESSAGE

        public static void LOG_DEBUG_MESSAGE​(Supplier<String> message)
        Print a debug message to System.out if gctoolkit.debug is empty, is set to "all", or contains "className" but does not contain "-className". For example, to enable debug logging for all classes except UnifiedG1GCParser: -Dgctoolkit.debug=all,-com.microsoft.gctoolkit.parser.UnifiedG1GCParser
        Parameters:
        message - Supplies the message to log. If null, nothing will be logged.
      • loadAggregationsFromServiceLoader

        public void loadAggregationsFromServiceLoader()
        Loads all Aggregations defined in the application module through the java.util.ServiceLoader model. To register a class that provides the Aggregation API, define the following in module-info.java:
         import com.microsoft.gctoolkit.aggregator.Aggregation;
         import com.microsoft.gctoolkit.sample.aggregation.HeapOccupancyAfterCollectionSummary;
         
         module com.microsoft.gctoolkit.sample {
             ...
             provides Aggregation with HeapOccupancyAfterCollectionSummary;
         }
         
      • loadAggregation

        public void loadAggregation​(Aggregation aggregation)
        Registers an Aggregation class which can be used to perform analysis on JVMEvents. GCToolKit will instantiate the Aggregation when needed.

        The JavaVirtualMachine.getAggregation(Class) API will return an Aggregation that was used in the log analysis. Even though an Aggregation was registered, the getAggregation method will return null if the Aggregation was not used in the analysis.

        Parameters:
        aggregation - the Aggregation class to register.
        See Also:
        Aggregation, JavaVirtualMachine
      • loadDataSourceChannel

        public void loadDataSourceChannel​(DataSourceChannel channel)
      • loadJVMEventChannel

        public void loadJVMEventChannel​(JVMEventChannel channel)
      • loadDataSourceParser

        public void loadDataSourceParser​(DataSourceParser dataSourceParser)
        This method allows full control over which DataSourceParsers are used to parse the DataSource. This method should be called before the analyze(DataSource) method. DataSourceParsers loaded by this method are used in place of those that are ordinarily loaded via the service provider interface. Use the addDataSourceParser(DataSourceParser) method to load a DataSourceParser in addition to those loaded by the service provider interface.
        Parameters:
        dataSourceParser - An implementation of DataSourceParser that will be used to parse the DataSource.
      • addDataSourceParser

        public void addDataSourceParser​(DataSourceParser dataSourceParser)
        Add a DataSourceParser to be used to parse a DataSource. The DataSourceParser will be used in addition to those loaded by the service provider interface. This method should be called before the analyze(DataSource) method.
        Parameters:
        dataSourceParser - An implementation of DataSourceParser that will be used to parse the DataSource.
      • analyze

        public JavaVirtualMachine analyze​(DataSource<?> dataSource)
                                   throws IOException
        Perform an analysis on a GC log file. The analysis will use the Aggregations that were registered, if appropriate for the GC log file.
        Parameters:
        dataSource - The log to analyze, typically a SingleGCLogFile or RotatingGCLogFile.
        Returns:
        a representation of the state of the Java Virtual Machine resulting from the analysis of the GC log file.
        Throws:
        IOException - when something goes wrong reading the data source