Typical memory-related problems can be recognized with the help of the "Inspections" feature. Inspections enable automatic high-level analysis of application memory. Each inspection automatically detects a specific memory issue. Performing this type of analysis by hand would be a very complicated (if at all possible) task.
With the help of inspections you can easily find the causes and possible solutions of usual memory-related problems.
The "Inspections" view is added to any tab representing objects, such as "All Objects" or any subset of objects. Inspections for all objects (i.e. for the entire snapshot) are also available via top-level tab "Inspections'.
(1) To run all inspections as a batch use "Run All Inspections" button.
(2) To run a single inspection, select it in the tree and use "Run This Inspection Only" button
(this is especially useful if you want to apply the changes made to an inspection's options).
All inspections are grouped by category:
- Possible memory waste
- Possible leaks
- Other oddities
Duplicate Strings
Find all java.lang.String's with identical text values.
Problem: Duplicate strings waste memory.
Possible solution: Share string instance via pooling or using intern().
Null Fields
Find instance fields with high percentage of 'null' values.
Problem: Possible memory waste.
Possible solutions: If some of the fields are not used, get rid of them rarely assigned fields can be moved to subclasses in the class hierarchy.
Sparse Arrays
Finds arrays with big number of 'null' elements.
Problem: Possible memory waste.
Possible solution: Use alternate data structures e.g. maps or rework algorithms.
Zero Length Arrays
Find multiple instances of zero-length arrays of particular type.
Problem: Memory waste and additional load for garbage collector.
Possible solution: Use empty array per-class singleton e.g. via a static field in class.
Objects Retained by Inner Class Back References
Find objects retained via synthetic back reference of its inner classes.
Problem: Such objects are potential memory leaks.
Lost SWT Controls
Find SWT control instances not accessible from shown UI.
Technically, it finds instances of org.eclipse.swt.widgets.Control which are not accessible from org.eclipse.swt.widgets.Display's field 'controlTable'
Problem: Possible memory leaks.
Possible solutions: Examine paths to lost objects to see if they really leaked
Highly Referenced Objects
Finds objects referenced by a large number of other objects.
Possible problems: Incorrect relations between objects in memory, logical errors and/or non-optimal data structures.
Classes Without Instances
Find classes with instance fields, but without live instances.
Problem: Possibly non-optimal class loading.
Self Referencing Objects
Finds objects with fields referencing 'this'.
Problem: Possibly incorrect logic and/or memory waste.
Possible solution: Remove redundant fields.

