#1122 infinite loop in writeChartAsPNG


When trying to call writeChartAsPNG with a width and height that is rather small (1), writeChartAsPNG loops and eventually ends up in a OutOfMemory exception. Of course 1 is a useless size, but it should return with an exception or do something else than looping.
Might be related to ticket 27.

Example code:

public class Test {

    public static void main(String[] args) {
        OutputStream output = new ByteArrayOutputStream();

        XYDataset dataset = new TimeSeriesCollection();
        JFreeChart chart = ChartFactory.createTimeSeriesChart("chart", "a", "b", dataset);

        int width = 1;
        int height = 1;

        try {
            ChartUtilities.writeChartAsPNG(output, chart, width, height, null);
        } catch (IOException e) {


  • David Gilbert

    David Gilbert - 2014-03-10

    I think you are probably running into this issue:


    If you download the latest JCommon version (1.0.22) the issue should be gone. Your test case is working for me with JCommon 1.0.22. I will close the bug, please reopen it if the issue is not resolved for you.

  • David Gilbert

    David Gilbert - 2014-03-10
    • status: open --> closed-fixed
    • assigned_to: David Gilbert
  • David Gilbert

    David Gilbert - 2014-03-10

    Fixed in JCommon version 1.0.22.


Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks