Memory Leak, ChartUtilities.saveChartAsPNG

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
daveb48
Posts: 10
Joined: Fri Dec 18, 2009 7:44 pm
antibot: No, of course not.

Memory Leak, ChartUtilities.saveChartAsPNG

Post by daveb48 » Fri Nov 05, 2010 6:56 pm

I'm getting a memory leak with a class that has operated for about a year, but starting with Java 1.5 - and it seems since upgrading to 1.6, the problem became severe: all my Jfreechart applications are leaking. Re-compiling with Java 1.5 makes no difference, however. It could be that I have added 6 new Java application programs recently.

Googling for several hours frequently mentions ChartUtilities.saveChartAsPNG as being the culprit - but no solutions have been posted.
Has anyone resolved this issue or found a work-around?

I am running on a Mac Xserve (OS v10.6), jfreechart-1.0.13, Java 1.6. The applications are launched every 15 minutes from a cron job. the JFreeChart class is instantiated in my code after I instantiate the CombinedDomainXYPlot class.

As I mentioned, these classes used to run just fine, and running them interactively shows no problems: the problem appears intermittently, making it hard to track down.

Thanks for any help.

daveb48
Posts: 10
Joined: Fri Dec 18, 2009 7:44 pm
antibot: No, of course not.

Re: Memory Leak, ChartUtilities.saveChartAsPNG

Post by daveb48 » Thu Nov 18, 2010 8:37 pm

Just an update,

I removed the saveChartAsPNG portion of the code (using jpg instead)... get the same error message... sometimes. I still believe it is associated with JFreeChart somehow (but is it because there is a OS X java lib glitch it is running into?). Any suggestion on how to isolate the problem somehow would be appreciated.

-Dave

daveb48
Posts: 10
Joined: Fri Dec 18, 2009 7:44 pm
antibot: No, of course not.

Re: Memory Leak, ChartUtilities.saveChartAsPNG

Post by daveb48 » Fri Nov 19, 2010 4:55 pm

I believe I have finally figured it out:

I added the following option in the cron job runtime command: -Djava.awt.headless=true

I had it in the class constructor, but it didn't seem to have any effect.

daveb48
Posts: 10
Joined: Fri Dec 18, 2009 7:44 pm
antibot: No, of course not.

Re: Memory Leak, ChartUtilities.saveChartAsPNG

Post by daveb48 » Tue Nov 23, 2010 5:50 pm

While my last change to adding -Djava.awt.headless=true to the JRE seemed to work, gradually the memory leaks been reappearing: It happens a lot less, but it is still occurring.
I'm really at a loss at this point.

Locked