I'm not sure that listing all the anonymous classes will take you anywhere, there are usually a lot of them.
You might need some logic to look for instances of classes that are stored by references to inner classes (which include anonymous classes).
JProfiler has a corresponding check:

The set of objects created during the scan contains all such instances, and you can then show the paths to the GC root:

Disclaimer: My company is developing JProfiler.
source share