Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8168930

Memory Leak issue with Charts

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      x86
    • OS:
      other

      Description

      FULL PRODUCT VERSION :
      Java jdk 1.8 u112 x64

      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1 x64

      A DESCRIPTION OF THE PROBLEM :
      it is the same like
      https://bugs.openjdk.java.net/browse/JDK-8096404
      but it is not fixed

      REGRESSION. Last worked in version 8u112

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start the programm,
      run with -Xmx30m
      wait
      after seconds an OutOfmemory is throws

      ACTUAL -
      OutOfMemory

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
          public static void main(String[] args) {
              launch(ChartMemoryLeak.class, args);
          }

          @Override
          public void start(final Stage stage) throws Exception {
              // Formatter for DateAxis
              final DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd.MM.yy");

              // Date Axis
              final NumberAxis xAxis = new NumberAxis(17101, 17127, 1);
              xAxis.setTickLabelFormatter(new LambdaMapStringConverter<Number>((input) -> LocalDate.ofEpochDay(input.longValue()).format(formatter)));
              xAxis.setTickLabelRotation(90);
              xAxis.setAutoRanging(false);

              // Number
              final NumberAxis yAxis = new NumberAxis();
              yAxis.setAutoRanging(true);

              // Chart
              final StackedAreaChart<Number, Number> ac = new StackedAreaChart<>(xAxis, yAxis);
              ac.setAnimated(false);

              // Stage
              stage.setTitle("Area Chart Sample");
              stage.setScene(new Scene(ac, 800, 600));
              stage.show();

              // Timer
              (new ChartDataThread(ac)).start();
          }

          /**
           * Create data in background<br>
           * Load Date from DB
           *
           * @author sst
           */
          private final class ChartDataThread extends Thread {
              /** Chart */
              private final StackedAreaChart<Number, Number> chart;

              /** Create Thread */
              private ChartDataThread(final StackedAreaChart<Number, Number> chart) {
                  super("ChartDataThread");
                  setPriority(Thread.MIN_PRIORITY);
                  setDaemon(true);
                  this.chart = chart;
              }

              @Override
              public void run() {
                  for (;;) {
                      try {
                          final List<Series<Number, Number>> data = new ArrayList<>();

                          LocalDate temp = LocalDate.now();;

                          for (int a = 0; a < 10; a++) {
                              final Series<Number, Number> series = new Series<>();
                              series.setName(String.valueOf(a));
                              data.add(series);

                              temp = LocalDate.now();

                              for (int b = 0; b < 40; b++) {
                                  series.getData().add(new Data<Number, Number>(temp.toEpochDay(), Integer.valueOf(a + b)));
                                  temp = temp.plusDays(1);
                              }
                          }

                          final LocalDate finish = temp;
                          Platform.runLater(() -> {
                              this.chart.getData().clear();

                              ((NumberAxis) this.chart.getXAxis()).setLowerBound(LocalDate.now().toEpochDay());
                              ((NumberAxis) this.chart.getXAxis()).setUpperBound(finish.toEpochDay());
                              ((NumberAxis) this.chart.getXAxis()).setTickUnit(1);

                              this.chart.getData().addAll(data);
                          });

                          Thread.sleep(32);
                      } catch (final Throwable throwable) {
                          throwable.printStackTrace();
                      }
                  }
              }
          }
      }
      ---------- END SOURCE ----------

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              jgiles Jonathan Giles
              Reporter:
              webbuggrp Webbug Group
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: