[jboss-dev-forums] [Design of JBoss Profiler] - Stripped down reference reports from JVMTIInterface
bstansberry@jboss.com
do-not-reply at jboss.com
Sat Mar 10 00:34:40 EST 2007
I'm loving using JVMTIInterface to generate classloader leak reports (see http://wiki.jboss.org/wiki/Wiki.jsp?page=ClassloaderLeakUnitTestCase) but I'm wondering if it makes sense to add a method that produces a report with a lot of the superfluous chains removed.
Basically, I'm thinking of something like exploreObject, but instead of writing to a PrintWriter, the method builds up a tree of Node objects that encapsulate the string entry for each explored data point (example class below.)
As it's building up the tree, if it finds a data point that refers to a java.lang.Reference or to an object that's already been explored, it throws a ref to the node into a Set. When it's gone through all the data points, it iterates over the nodes in the set, calling removeBranch() on each. That will prune all branches from the tree that lead to Reference pointers or to objects that would be gc'd if the real leak is fixed.
Then call toString() on the root node to get the slimmed down report.
Does this make sense?
| class Node {
| final String message;
| List<Node> children = new ArrayList<Node>();
| Node parent;
|
| Node(String msg) {
| this.message = msg;
| }
|
| void addChild(Node child) {
| children.add(child);
| child.setParent(this);
| }
|
| void removeChild(child) {
| children.remove(child);
| if (children.size() == 0)
| removeBranch();
| }
|
| void removeBranch() {
| if (parent != null)
| parent.removeChild(this);
| }
|
| void setParent(Node parent) {
| this.parent = parent;
| }
|
| String toString() {
| String result = msg + "\n";
| for (Iterator it = children.iterator(); it.hasNext();)
| result += it.next().toString();
| }
| }
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4026837#4026837
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4026837
More information about the jboss-dev-forums
mailing list