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

Ensemble: delayTimeline timelines from DigitalClock$Clock are not always stopped which could lead to OOM

    Details

      Description

      There is a memory leak in Ensemble DigitalClock sample.

      delayTimeline timelines created in DigitalClock$Clock are not always stopped.
      I instrumented DigitalClock sample and this is because Clock.play() is called 2 times
      while Clock.stop() is called only once. As result running reliability Ensemble2AutoTest
      with 128m of heap size and only DigitalClock and ColorfulShapes samples fails with OOM
      after 552 iterations. The interesting is that this happens in j2d pipeline on low-end machines
      (it works fine on win7-high end machine).

      Also note that delayTimeline is created with default cycle count which is 1 and as results
      is supposed to be stopped automatically and GC collected. Looks like this doesn't happen quick enough
      (after 552 iterations there are 134 Timelines left) which leads to OOM. The heap histogram is the following:
      Class Name | Objects | Shallow Heap | Retained Heap
      -------------------------------------------------------------------------------------
      byte[] | 7,434 | 80,260,280 | >= 80,260,280
      java.awt.image.BufferedImage | 97 | 3,880 | >= 45,132,912
      java.lang.Class | 4,352 | 32,664 | >= 41,969,656
      java.nio.HeapByteBuffer | 102 | 4,896 | >= 40,088,176
      com.sun.prism.Image | 97 | 3,880 | >= 40,050,776
      java.util.WeakHashMap | 31 | 1,488 | >= 39,551,208
      java.util.WeakHashMap$Entry | 215 | 8,600 | >= 39,544,192
      java.util.WeakHashMap$Entry[] | 31 | 4,472 | >= 39,540,208
      com.sun.prism.impl.BaseResourceFactory | 0 | 0 | >= 39,538,544
      com.sun.prism.j2d.J2DTexture | 89 | 2,136 | >= 39,533,856
      sun.awt.image.ByteInterleavedRaster | 70 | 8,400 | >= 39,337,608
      com.sun.javafx.tk.desktop.MasterTimer | 1 | 72 | >= 29,142,312
      ensemble.samples.graphics.DigitalClock$Clock| 64 | 17,920 | >= 16,779,296
      javafx.animation.Timeline | 134 | 15,008 | >= 14,049,104
      -------------------------------------------------------------------------------------


      While it would be nice to understand better why Timelines are not stopped in time DigitalClock sample needs to be fixed anyway.
      Here is the possible fix which fixes he issue:

      > hg diff DigitalClock.java
      diff -r d62468d72872 ga-samples/Ensemble/src/ensemble/samples/graphics/DigitalClock.java
      --- a/ga-samples/Ensemble/src/ensemble/samples/graphics/DigitalClock.java Wed Feb 15 12:50:49 2012 -0800
      +++ b/ga-samples/Ensemble/src/ensemble/samples/graphics/DigitalClock.java Fri Feb 17 16:06:11 2012 -0800
      @@ -136,7 +136,10 @@
               }
       
               public void play() {
      - // wait till start of next second then start a timeline to call refreshClocks() every second
      + if (delayTimeline != null)
      + delayTimeline.stop();


      However, I would recommend to find out why Clock.play() is called in twice bigger than Clock.stop()
      and fix that. This is the core issue.

        Attachments

          Activity

            People

            • Assignee:
              dmasada Debra Masada (Inactive)
              Reporter:
              epavlova Ekaterina Pavlova
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: