/** * Returns the sum of the size of primitive/simple value data contained within this node. This will differ from the * serialized size, as references to shared objects aren't followed/counted. * * @return the actual data size, in bytes. */ public int getSize() { int dataSize = size; for (int i = 0; i < getChildCount(); i++) { dataSize += ((ObjectGraphNode) getChildAt(i)).getSize(); } return dataSize; }
((ObjectGraphNode) getChildAt(i)).toXml(newIndent, xml);
/** * Generates a flat format summary XML representation of this ObjectGraphNode. * * @param indent the indent, for formatting. * @param buffer the StringBuffer to append the summary to. */ private void toFlatSummary(final String indent, final StringBuffer buffer) { buffer.append(indent); ObjectGraphNode root = (ObjectGraphNode) getRoot(); double pct = 100.0 * getSize() / root.getSize(); buffer.append(getSize()).append(" ("); buffer.append(new DecimalFormat("0.0").format(pct)); buffer.append("%) - ").append(getFieldName()).append(" - "); if (getRefNode() != null) { buffer.append("ref (").append(getRefNode().getValue().getClass().getName()).append(')'); } else if (getValue() == null) { buffer.append("null (").append(getType()).append(')'); } else { buffer.append(getType()); } buffer.append('\n'); String newIndent = indent + " "; for (int i = 0; i < getChildCount(); i++) { ((ObjectGraphNode) getChildAt(i)).toFlatSummary(newIndent, buffer); } }
LOG.info(((ObjectGraphNode) root.getChildAt(0)).toXml()); LOG.info(((ObjectGraphNode) root.getChildAt(1)).toXml()); } catch (Exception e) { LOG.error("Failed to dump context", e);
ObjectGraphNode root = ObjectGraphDump.dump(treeAndSession); LOG.info(LINE_PREFIX + "Component mem use: " + ((ObjectGraphNode) root.getChildAt(0)). getSize()); LOG.info(LINE_PREFIX + "UIC mem use: " + ((ObjectGraphNode) root.getChildAt(1)). getSize()); } finally {
/** * Adjusts the overhead of the given node, for types where not all data is output (e.g. Lists and Maps). * * @param node the node to adjust. */ private void adjustOverhead(final ObjectGraphNode node) { ObjectGraphNode[] originalChildren = new ObjectGraphNode[node.getChildCount()]; int dataSize = 0; for (int i = 0; i < node.getChildCount(); i++) { ObjectGraphNode childNode = (ObjectGraphNode) node.getChildAt(i); dataSize += childNode.getSize(); originalChildren[i] = childNode; } node.removeAll(); // Figure out the list overhead. // All the original children will be included refs, as they have already been visited. visitComplexType(node); node.setSize(node.getSize() - originalChildren.length * ObjectGraphNode.OBJREF_SIZE); // re-attach the old children node.removeAll(); for (int i = 0; i < originalChildren.length; i++) { node.add(originalChildren[i]); } }