The profiler provides a very powerful way to detect memory leak -
calculation of paths between objects in memory.
A path is a very simple and intuitive concept. A path between Object 1 and Object n is a sequence of objects where:
When you have found a leaked object and want to fix the memory leak, use paths from GC roots to find out why that object is retained in memory.
To see the paths, select an object and switch to Paths from GC Roots:
You can limit the number of paths to show. It is guaranteed that the shortest paths are shown first, i.e. there are no paths shorter than the ones displayed.
Also, you can explicitly invoke Memory | Paths from GC Roots... (Ctrl+P) to open the paths in a new tab.
You can ignore particular references in paths. This feature is a great aid when investigating memory leaks, because it immediately shows whether nulling particular reference eliminates the leak, and if not, which remaining references you should also consider.
Memory | Paths between Predefined Sets... is the most common way to find out how an object of the source set references objects of the target set.