Community
Participate
Working Groups
Following the comments from bug 299371, the ISnapshot interface should provide methods for calculating the reachable set of a set of objects
Created attachment 165285 [details] Add a getReachableSet() method to ISnapshot, its implementation, and a query which uses it
I have made an initial implementation of the ISnapshot.getReachableSet(). However, the use of the results of the query is very questionable. The problem is that if we follow all outbound references for almost any object or set of objects we get almost the whole heap. This is because of the implicit references to class and classloader. Below is a sample how from a simple instance of a String we can reach it's class, classloader, all classes loaded with this classloader, and so on... Class Name | Shallow Heap | Retained Heap ------------------------------------------------------------------------------------------------------------------------------- java.lang.String @ 0x50a34310 Configure ... | 24 | 64 |- <class> class java.lang.String @ 0x4ec47af8 System Class, Native Stack | 16 | 40 | |- <class> class java.lang.Class @ 0x4ec47c78 System Class, Native Stack | 40 | 56 | |- <classloader> java.lang.ClassLoader @ 0x0 <system class loader> | 56 | 56 | | '- <class> class java.lang.ClassLoader @ 0x4ec4e990 System Class | 32 | 976 | | |- <class> class java.lang.Class @ 0x4ec47c78 System Class, Native Stack | 40 | 56 | | |- <classloader> java.lang.ClassLoader @ 0x0 <system class loader> | 56 | 56 | | |- scl sun.misc.Launcher$AppClassLoader @ 0x1cc30778 | 72 | 2.048 | | | |- <class> class sun.misc.Launcher$AppClassLoader @ 0x4eda20f0 System Class | 8 | 8 | | | |- parent sun.misc.Launcher$ExtClassLoader @ 0x1cc376a8 | 80 | 4.656 | | | |- package2certs java.util.Hashtable @ 0x1cc376f0 | 40 | 168 | | | |- classes java.util.Vector @ 0x1cc37718 | 32 | 88 | | | | |- <class> class java.util.Vector @ 0x4ec82830 System Class | 8 | 8 | | | | |- elementData java.lang.Object[10] @ 0x1cc41358 | 56 | 56 | | | | | |- <class> class java.lang.Object[] @ 0x4eca5308 | 0 | 0 | | | | | |- [0] class org.eclipse.equinox.launcher.Main @ 0x4ef21868 | 352 | 2.192 | | | | | |- [1] class org.eclipse.equinox.launcher.Main$EclipsePolicy @ 0x4ef23710 | 0 | 0 | | | | | |- [2] class org.eclipse.equinox.launcher.Main$StartupClassLoader @ 0x4ef24d20| 0 | 0 | | | | | |- [3] class org.eclipse.equinox.launcher.Main$SplashHandler @ 0x4ef26688 | 0 | 0 | | | | | |- [4] class org.eclipse.equinox.launcher.JNIBridge @ 0x4ef2bc00 | 0 | 0 ------------------------------------------------------------------------------------------------------------------------------- We have to find first a proper way to limit the marking (if there is some proper way). I though of - not marking through the implicit references - not marking through GC roots - not marking through classes or classloaders in general but for any of these there seems to be a case where it is useful to be done. Therefore I will postpone this change for now (not do it for our planned 1.0 release). I have attached my changes as a patch, so that it is easier to try the effect of the query.
This change needs some more time and discussions and we won't do it for 1.0. I remove the link to bug 299371 - API changes for 1.0.
This issue has been migrated to https://github.com/eclipse-mat/org.eclipse.mat/issues/8.