Graphviz Issue Tracker
Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000739graphvizGrappapublic2007-06-22 18:202011-04-28 04:03
ReporterMike Thyer 
Assigned Togviz 
PlatformOS*-*-OS Version
Summary0000739: memory leak in Grappa

Grappa leaks memory and gets progressively slower when using the same Graph object to step through multiple graphs on a GrappaPanel.
The problem only occurs when there are default attributes set.
The cause seems to be the GrappaNexus observers which are registered for the default attributes but never removed.
The list of observers continually grows, and the removal of node-specific attributes becomes progressively slower.

The program below demonstrates the symptoms.
Within a minute speed has noticeably dropped and memory usage is continually increases.
import att.grappa.Graph;
import att.grappa.Node;
import att.grappa.Edge;
import att.grappa.Parser;
import att.grappa.GrappaPanel;
import att.grappa.GrappaSupport;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;

class GrappaMemoryLeak {
    static Graph graph = new Graph("");
    static final int numNodes = 10;
    static String [] graphStr = new String [numNodes];
    static int step=0;

    public static void main(String[] args) {

    static Runnable init = new Runnable () {
        public void run() {
            graph.setNodeAttribute("style", "bold");
            GrappaPanel panel = new GrappaPanel (graph);
            Node [] nodes = new Node [numNodes];
            for (int i=0; i != numNodes; i++) {
                nodes[i] = new Node(graph, "node"+i);
                for (int j=0; j != i; j++) {
                    new Edge (graph, nodes[i], nodes[j]);
                StringWriter writer = new StringWriter ();
                String [] dotArgs = {"dot"};
                try {
                    Process dotProcess = Runtime.getRuntime().exec(dotArgs, null, null);
                    GrappaSupport.filterGraph(graph, dotProcess);
                catch (Exception exc) {
                    throw new Error (exc);
                graphStr[i] = writer.toString();

            JFrame window = new JFrame();
            window.setLocation (10,30);
            window.setSize (640,480);


    static Runnable loop = new Runnable () {
        public void run() {
            try {
                Parser parser = new Parser (new StringReader(graphStr[step%numNodes]), null, graph);
            catch (Exception exc) {
                throw new Error (exc);
TagsNo tags attached.
commenting out this line in is a work-around:
1406: attr.addObserver(grappaNexus);
but must almost certainly break some feature I'm not using.
VERSION     Grappa 2006-10-10
Attached Files

- Relationships

-  Notes
There are no notes attached to this issue.

- Issue History
Date Modified Username Field Change
2011-04-28 04:03 user1 New Issue
2011-04-28 04:03 user1 Assigned To => user1

MantisBT 1.2.5[^]
Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker