Batch mode

Memory Analyzer can be operated in batch mode to process heap dumps without user input.

  1. Note: On Windows, use .\mat\ParseHeapDump.bat instead of ./mat/ParseHeapDump.sh
    Run ./mat/ParseHeapDump.sh myheapdump.hprof org.eclipse.mat.api:suspects
    • For a simple suspects report use org.eclipse.mat.api:suspects See running leak suspect report for more details.
    • For an overview report use org.eclipse.mat.api:overview This report is included at the beginning of the leak suspects report and shows:
      • Heap Dump Overview
      • System Properties
      • Thread Overview
      • Top Consumers
      • Class Histogram
    • For a report on memory usage by component use org.eclipse.mat.api:top_components See Component report for more details of the report run on each of the top components by memory usage.
    • To compare two heap dumps use ./mat/ParseHeapDump.sh myheapdump.hprof -snapshot2=myheapdump2.hprof org.eclipse.mat.api:compare
    • To compare two heap dumps for memory leaks with a leak suspects report use ./mat/ParseHeapDump.sh myheapdump.hprof -baseline=myheapdump2.hprof org.eclipse.mat.api:suspects2 See running leak suspect report by snapshot comparison for more details.
    • To export a new copy of the heap dump with redactions use a command like
      
      ./mat/ParseHeapDump.sh
      myheapdump.hprof
      -output=myheapdump2.hprof
      -redact=BASIC
      -map=myheapdump2.map
      org.eclipse.mat.hprof:export
      					
      See export heap dump for more details.
    • To run a single query on a heap dump and produce an HTML report use ./mat/ParseHeapDump.sh myheapdump.hprof -command=histogram org.eclipse.mat.api:query See Query Report for more details.
  2. Choose additional options to control the parse and report generation.
    Command line options controlling the parse.
    1. -keep_unreachable_objects means that all objects are retained in the snapshot, even if they are not reachable from an ordinary GC root.
    2. -snapshot_identifier=identifier Selects one snapshot when there is the choice of several in the heap dump file. For HPROF files this might be of the form #1 or #2. For DTFJ system dump files this might be of the form Address space ID.Process ID.Runtime ID. If there are multiple snapshots in a heap dump file and a specific snapshot is not selected then the parse will fail with a org.eclipse.mat.snapshot.MultipleSnapshotsException which will list appropriate possible snapshot identifiers to use with this option.
    3. Note: Experimental
      -discard_ratio=percentage. Option to discard a fraction of the objects from huge dumps.
      See discard configuration for an explanation of these discard options.
    4. Note: Experimental
      -discard_pattern=regex. A regular expression matching the class names of objects to be discarded.
    5. Note: Experimental
      -discard_offset=offset value. Controls which particular objects are discarded.
    6. Note: Experimental
      -discard_seed=random number generator seed. Controls which particular objects are discarded.
    7. Other report options

      Other parameters controlling output include the following:

      Argument Description
      -limit=number of entries Controls the number of entries generated in an output table. See org.eclipse.mat.report.Params.Rendering.LIMIT
      -format=type of output Controls the type of the output (HTML, CSV, or TXT). See org.eclipse.mat.report.Params.FORMAT
      -html.show_table_headings Controls whether table headings should be shown for tables. See org.eclipse.mat.report.Params.Html.SHOW_TABLE_HEADER
      -html.show_totals Controls whether totals should be shown for tables. See org.eclipse.mat.report.Params.Html.SHOW_TOTALS
    Task: Parsing myheapdump.hprof
    [Task: Parsing .\Downloads\myheapdump.hprof
    [
    Subtask: Scanning .\Downloads\myheapdump.hprof
    [.................
    [INFO] Detected compressed references, because with uncompressed 64-bit references the array at 0x5c4bd4258 would overlap the array at 0x5c4bd4230
    [....................
    [INFO] Wrote threads call stacks to .\Downloads\myheapdump.threads
    [....................
    [INFO] Heap .\Downloads\myheapdump.hprof contains 116,716 objects
    [....................
    Subtask: Extracting objects from .\Downloads\myheapdump.hprof
    [...................................................................................Task: Removing unreachable objects
    [
    Subtask: Searching for unreachable objects
    [
    Subtask: Marking reachable objects
    [.
    Subtask: Re-indexing objects
    [..
    Subtask: Re-indexing classes
    [...
    Subtask: Writing .\Downloads\myheapdump.idx.index
    [....
    Subtask: Writing .\Downloads\myheapdump.o2c.index
    [.....
    Subtask: Writing .\Downloads\myheapdump.a2s.index
    [......
    Subtask: Re-indexing outbound index
    [.......
    Subtask: Writing .\Downloads\myheapdump.inbound.index
    [........
    Subtask: Writing .\Downloads\myheapdump.outbound.index
    [.........
    Subtask: Writing .\Downloads\myheapdump.o2hprof.index
    [.........Task: Calculating Dominator Tree
    [
    Subtask: Dominator Tree calculation
    [
    Subtask: Depth-first search
    [....................
    Subtask: Computing dominators
    [..............................................
    Subtask: Calculate retained sizes
    [............................................................
    Subtask: Create dominators index file
    [................................................................................]
    
    Subtask: Test 'Heap Dump Overview' of section 'System Overview'
    [
    Subtask: Test 'System Properties' of section 'System Overview'
    [
    Subtask: Extracting Key Value Pairs...
    [
    Subtask: Test 'Thread Overview' of section 'System Overview'
    [
    Subtask: Searching Threads...
    [
    Subtask: Test 'Top Consumers' of section 'System Overview'
    [
    Subtask: Creating histogram
    [
    Subtask: Grouping by package
    [
    Subtask: Test 'Biggest Objects (Overview)' of section 'Top Consumers'
    [
    Subtask: Test 'Biggest Objects' of section 'Top Consumers'
    [
    Subtask: Test 'Biggest Top-Level Dominator Classes (Overview)' of section 'Top Consumers'
    [
    Subtask: Test 'Biggest Top-Level Dominator Classes' of section 'Top Consumers'
    [
    Subtask: Test 'Biggest Top-Level Dominator Class Loaders (Overview)' of section 'Top Consumers'
    [
    Subtask: Test 'Biggest Top-Level Dominator Class Loaders' of section 'Top Consumers'
    [
    Subtask: Test 'Biggest Top-Level Dominator Packages' of section 'Top Consumers'
    [
    Subtask: Test 'Class Histogram' of section 'System Overview'
    [
    Subtask: Test 'Leaks' of section 'Leak Suspects'
    [
    Subtask: Finding problem suspects
    [
    Subtask: Searching suspicious single objects ...
    [
    Subtask: Searching suspicious groups of objects ...
    [
    Subtask: building histogram
    [
    Subtask: Preparing results
    [
    Subtask: building histogram
    [
    Subtask: building histogram
    [
    Subtask: Finding paths
    [
    Subtask: Test 'Overview' of section 'Leaks'
    [
    Subtask: Test 'Problem Suspect 1' of section 'Leaks'
    [
    Subtask: Test 'Description' of section 'Problem Suspect 1'
    [
    Subtask: Test 'Shortest Paths To the Accumulation Point' of section 'Problem Suspect 1'
    [
    Subtask: Test 'Shortest Paths To the Accumulation Point' of section 'Problem Suspect 1'
    [
    Subtask: Test 'Accumulated Objects in Dominator Tree' of section 'Problem Suspect 1'
    [
    Subtask: Test 'Accumulated Objects in Dominator Tree' of section 'Problem Suspect 1'
    [
    Subtask: Test 'Accumulated Objects by Class in Dominator Tree' of section 'Problem Suspect 1'
    [
    Subtask: Test 'Accumulated Objects by Class in Dominator Tree' of section 'Problem Suspect 1'
    [
    Subtask: Test 'All Accumulated Objects by Class' of section 'Problem Suspect 1'
    [
    Subtask: Test 'All Accumulated Objects by Class' of section 'Problem Suspect 1'
    []
    					
  3. Unzip the report myheapdump_Leak_Suspects.zip
  4. View the index.html

The result is a HTML report.