mat icon indicating copy to clipboard operation
mat copied to clipboard

Add method for calculating the reachable set to ISnapshot

Open eclipsewebmaster opened this issue 1 year ago • 3 comments
trafficstars

| --- | --- | | Bugzilla Link | 309646 | | Status | NEW | | Importance | P3 enhancement | | Reported | Apr 19, 2010 06:07 EDT | | Modified | May 22, 2013 04:54 EDT | | Reporter | Krum Tsvetkov |

Description

Following the comments from bug 299371, the ISnapshot interface should provide methods for calculating the reachable set of a set of objects

eclipsewebmaster avatar May 08 '24 18:05 eclipsewebmaster

By Krum Tsvetkov on Apr 19, 2010 10:31

Created attachment 165285 Add a getReachableSet() method to ISnapshot, its implementation, and a query which uses it

:notepad_spiral: org.eclipse.mat.api.patch

eclipsewebmaster avatar May 08 '24 18:05 eclipsewebmaster

By Krum Tsvetkov on Apr 19, 2010 10:31

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 java.lang.String @ 0x4ec47af8 System Class, Native Stack | 16 | 40
| |- class java.lang.Class @ 0x4ec47c78 System Class, Native Stack | 40 | 56
| |- java.lang.ClassLoader @ 0x0 | 56 | 56
| | '- class java.lang.ClassLoader @ 0x4ec4e990 System Class | 32 | 976
| | |- class java.lang.Class @ 0x4ec47c78 System Class, Native Stack | 40 | 56
| | |- java.lang.ClassLoader @ 0x0 | 56 | 56
| | |- scl sun.misc.Launcher$AppClassLoader @ 0x1cc30778 | 72 | 2.048
| | | |- 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 java.util.Vector @ 0x4ec82830 System Class | 8 | 8
| | | | |- elementData java.lang.Object[10] @ 0x1cc41358 | 56 | 56
| | | | | |- 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.

eclipsewebmaster avatar May 08 '24 18:05 eclipsewebmaster

By Krum Tsvetkov on Apr 23, 2010 04:13

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.

eclipsewebmaster avatar May 08 '24 18:05 eclipsewebmaster