8000 [Fix #122] Don't auto-expand InspectorView class hierarchy for java.lang.Object by kgibm · Pull Request #127 · eclipse-mat/mat · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

[Fix #122] Don't auto-expand InspectorView class hierarchy for java.lang.Object #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 22, 2025

Conversation

kgibm
Copy link
Member
@kgibm kgibm commented Apr 23, 2025

Fixes #122 performance issue

@kgibm
Copy link
Member Author
kgibm commented Apr 23, 2025

@jasonk000 or @krumts: if one of you can please review when you have a chance, thanks!

ECA is down again but we know why that check is failing now. It was up earlier today for PR #124 and I just did git commit --amend and git push -f and then it worked (while it was up).

…y for java.lang.Object

Signed-off-by: Kevin Grigorenko <kevin.grigorenko@us.ibm.com>
Copy link
Contributor
@jasonk000 jasonk000 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good find!

Change LGTM if you want to proceed.

I also propose a slight alternative, that should more safely do this for any class that is selected, by only opening to one-level below the class.

-   classHierarchyTree.expandAll();
+   // value 2 expands one level deeper than selected class
+   int levelsToRoot = findIClassLevelsToRoot(input);
+   classHierarchyTree.expandToLevel(2 + levelsToRoot);

and

+    private static int findIClassLevelsToRoot(IClass input)
+    {
+        int levelsToRoot = 0;
+        IClass parent = input.getSuperClass();
+        while (parent != null)
+        {
+            levelsToRoot++;
+            parent = parent.getSuperClass();
+        }
+        return levelsToRoot;
+    }

Resulting view, everything is expanded to one-below the selected item, in this case the selected item is the thread object

image

@kgibm
Copy link
Member Author
kgibm commented May 22, 2025

I also propose a slight alternative, that should more safely do this for any class that is selected, by only opening to one-level below the class.

I tested the three approaches:

  1. Current behavior = 12143ms
  2. Skip expanding on the root class = 0ms
  3. Opening to one-level below the class = 70ms

So opening to one-level below is much faster than the current behavior though even with a relatively small heap dump, it was nearly noticeable, and this will scale with the number of classes with larger heaps. I could imagine this could get into the hundreds of milliseconds range which is not too big a deal but might get noticeable. Also worth noting that this is done even if the Class Hierarchy view is not visible. On the flip side, your solution is more generic and would handle the cases of a class that's not java.lang.Object that has a very deep hierarchy. So from that point of view, I like your solution better. I'll change to it when I get some cycles.

…epth

Signed-off-by: Kevin Grigorenko <kevin.grigorenko@us.ibm.com>
@kgibm
Copy link
Member Author
kgibm commented May 22, 2025

Updated commit and ran full tests locally

@kgibm kgibm merged commit 34251d6 into eclipse-mat:master May 22, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

UI Freezes When Accessing Particular Object Properties
2 participants
0