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

Ensemble: memory leak in DigitalClock sample

XMLWordPrintable

      secondTimeline objects created as part of delayTimeline are never stopped
      which leads to memory growth and potential OOM.

      Modifying delayTimeline the following way fixes the issue:

         144 @Override public void handle(ActionEvent event) {

      if (secondTimeline != null)
         secondTimeline.stop();

         145 secondTimeline = new Timeline();
         146 secondTimeline.setCycleCount(Timeline.INDEFINITE);
         147 secondTimeline.getKeyFrames().add(
         148 new KeyFrame(Duration.seconds(1), new EventHandler<ActionEvent>() {
         149 @Override public void handle(ActionEvent event) {
         150 refreshClocks();
         151 }
         152 }));
         153 secondTimeline.play();
         154 }

      I am not sure this is correct fix from DigitalClock functionality, so please
      provide another one in case this is the case.

            dmasada Debra Masada (Inactive)
            epavlova Ekaterina Pavlova
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: