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

BufferedImageGraphics2D.drawLine does unnecessary work and memory allocation

XMLWordPrintable

    • 2d
    • beta
    • x86
    • windows_nt


      BufferedImageGraphics2D.drawLine has a fairly serious performance hole.

      Every time it is executed it checks where it has a
      DrawLineRasterContext allocated. If not it tries to allocate one.
      This may or may not succeed. It then draws the line.

      Unfrotunately it doesn't remember if it *fails* to allocate a
      DrawLineRasterContext. Unfortunately if the graphics context
      is such that it can't get one, it still pays a significant
      time and memory cost each time through drawLine trying to
      allocate one.

      This showed up in the Swing startup code during the painting of
      MetalBumps. Even after that code was changed to avoid doing
      setColors, repeated calls on drawLine with the same graphics
      context were causing a large memory leak.

      This was adding three seconds to Swing startup on a 150 MHz pentium.
      See the workaround section for a change to the drawLine method
      that removed that overhead.

      graham.hamilton@Eng 1998-06-08

            flar Jim Graham
            ghamiltosunw Graham Hamilton (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: