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

SurfaceManager cacheMap retains strong references

XMLWordPrintable

    • 2d
    • b21

      This prevents otherwise unused objects to be garbage collected.

      Namely, GraphicsConfiguration gets stuck in the cache as follows:
      key -> GraphicsConfig
      value -> SurfaceDataProxy -> GraphicsConfig

      Therefore, just replacing the map with WeakHashMap is not sufficient.

      Steps to reproduce:
      1. Run attached GraphicsConfigLeakTest
      2. Attach external display
      3. Deattach external display
      4. Take a heap dump and inspect incoming references for the graphics config objects
      5. See old configs retained by the BufferedImage, like this:
      - sun.java2d.metal.MTLGraphicsConfig
      - key of java.util.concurrent.ConcurrentHashMap$Node
      - java.util.concurrent.ConcurrentHashMap$Node[8]
      - table of java.util.concurrent.ConcurrentHashMap
      - cacheMap of sun.awt.image.BufImgSurfaceManager
      - surfaceManager of java.awt.image.BufferedImage
      - image of GraphicsConfigLeakTest

            ngubarkov Nikita Gubarkov
            ngubarkov Nikita Gubarkov
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: