graphviz-java icon indicating copy to clipboard operation
graphviz-java copied to clipboard

Memory leak?

Open armin-reichert opened this issue 5 years ago • 2 comments

I use your great library for live visualization of the state machines driving a Pac-Man game implementation (https://github.com/armin-reichert/pacman).

There is an integrated dashboard showing 4 state machine graphs (PNGs) at the same time and each state machine image is updated 5 times/sec. After several minutes I get OutOfMemory errors from the Javascript engine. I use 20_000_000 as Graphviz memory in my call to render the graph:

BufferedImage png = Graphviz.fromString(data.getGraph()).totalMemory(GRAPHVIZ_MEMORY).scale(scaling) .render(Format.PNG).toImage();

Isn't this a useful value or is there a known memory leak?

armin-reichert avatar Aug 13 '20 11:08 armin-reichert

That's probably not the most common use case, but interesting. looks like a leak, i'll see what i can do.

nidi3 avatar Aug 13 '20 17:08 nidi3

Thank you for answering. Today I switched from Nashorn to the V8 JS engine but after some minutes the error still occurs:

`Exception in thread "AWT-EventQueue-0" guru.nidi.graphviz.engine.GraphvizException: Got Error: 'TypeError: Module.print is not a function'. This is probably an out of memory error. Try using the totalMemory method. at guru.nidi.graphviz.engine.ResultHandler.waitFor(ResultHandler.java:42) at guru.nidi.graphviz.engine.V8JavascriptEngine.execute(V8JavascriptEngine.java:56) at guru.nidi.graphviz.engine.AbstractJavascriptEngine.executeJavascript(AbstractJavascriptEngine.java:28) at guru.nidi.graphviz.engine.AbstractJsGraphvizEngine.jsVizExec(AbstractJsGraphvizEngine.java:105) at guru.nidi.graphviz.engine.AbstractJsGraphvizEngine.execute(AbstractJsGraphvizEngine.java:96) at guru.nidi.graphviz.engine.Graphviz.doExecute(Graphviz.java:312) at guru.nidi.graphviz.engine.Graphviz.execute(Graphviz.java:292) at guru.nidi.graphviz.engine.Renderer.execute(Renderer.java:139) at guru.nidi.graphviz.engine.Renderer.toImage(Renderer.java:110) at de.amr.games.pacman.view.dashboard.fsm.FsmGraphView.update(FsmGraphView.java:81) at de.amr.games.pacman.view.dashboard.fsm.FsmDashboard.update(FsmDashboard.java:125) at de.amr.games.pacman.view.dashboard.fsm.FsmView.update(FsmView.java:162) at de.amr.easy.game.ui.f2dialog.core.F2DialogImpl.update(F2DialogImpl.java:140)

I changed my application to count the number of images rendered until the error occurs and found this:

The error occurs after 3342, 6681, 10020, 13359, 16698, 20037, 23376, ... rendered images.

Looks very regularly to me.

armin-reichert avatar Aug 14 '20 08:08 armin-reichert