Bug 309646 - Add method for calculating the reachable set to ISnapshot
Summary: Add method for calculating the reachable set to ISnapshot
Status: CLOSED MOVED
Alias: None
Product: MAT
Classification: Tools
Component: Core (show other bugs)
Version: unspecified   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-19 06:07 EDT by Krum Tsvetkov CLA
Modified: 2024-05-08 14:35 EDT (History)
0 users

See Also:


Attachments
Add a getReachableSet() method to ISnapshot, its implementation, and a query which uses it (6.56 KB, patch)
2010-04-19 10:31 EDT, Krum Tsvetkov CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Krum Tsvetkov CLA 2010-04-19 06:07:13 EDT
Following the comments from bug 299371, the ISnapshot interface should provide methods for calculating the reachable set of a set of objects
Comment 1 Krum Tsvetkov CLA 2010-04-19 10:31:41 EDT
Created attachment 165285 [details]
Add a getReachableSet() method to ISnapshot, its implementation, and a query which uses it
Comment 2 Krum Tsvetkov CLA 2010-04-19 10:31:56 EDT
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.
Comment 3 Krum Tsvetkov CLA 2010-04-23 04:13:49 EDT
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.
Comment 4 Eclipse Webmaster CLA 2024-05-08 14:35:05 EDT
This issue has been migrated to https://github.com/eclipse-mat/org.eclipse.mat/issues/8.