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

Memory Leak issue with Charts / WeakReferences / Platform.accessibilityActiveProperty()

    XMLWordPrintable

Details

    Description

      FULL PRODUCT VERSION :
      1.8 Update 112 x64

      ADDITIONAL OS VERSION INFORMATION :
      Windows 8.1 x64

      A DESCRIPTION OF THE PROBLEM :
      https://bugs.openjdk.java.net/browse/JDK-8168930
      https://bugs.openjdk.java.net/browse/JDK-8096404

      http://194.25.240.197:9980/chart.memory.leak.png
      http://194.25.240.197:9980/chart.memory.leak.7z

      on Produktion system i use an intervall from 1 minute and 1gb
      the oom is throws after 6 days

      REGRESSION. Last worked in version 8u112

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Start the programm
      -Xmx100m
      -XX:+HeapDumpOnOutOfMemoryError

      lanuch visual vm
      sample memory with "java.lang.ref"

      wait
      after seconds an OutOfmemory is throws


      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package ChartMemoryLeak;

      import java.time.LocalDate;
      import java.time.format.DateTimeFormatter;
      import java.util.ArrayList;
      import java.util.List;

      import javafx.application.Application;
      import javafx.application.Platform;
      import javafx.scene.Scene;
      import javafx.scene.chart.NumberAxis;
      import javafx.scene.chart.StackedAreaChart;
      import javafx.scene.chart.XYChart.Data;
      import javafx.scene.chart.XYChart.Series;
      import javafx.stage.Stage;
      import javafx.util.StringConverter;

      /**
       * @author sst
       */
      public class ChartMemoryLeak2 extends Application {

          public static void main(String[] args) {
              launch(ChartMemoryLeak2.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 StringConverter<Number>() {
                  
                  @Override
                  public String toString(final Number object) {
                      return LocalDate.ofEpochDay(object.longValue()).format(formatter);
                  }
                  
                  @Override
                  public Number fromString(final String string) {
                      return LocalDate.parse(string, formatter).toEpochDay();
                  }
              });

              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(128);
                      } catch (final Throwable throwable) {
                          throwable.printStackTrace();
                      }
                  }
              }
          }
      }

      ---------- END SOURCE ----------

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: