Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: current
    • Fix Version/s: milestone 1
    • Component/s: jogl
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      315

      Description

      When using an Overlay object to create a graphics context to paint with Java2D,
      calling dispose on the graphics context is not enough - the underlying
      TextureRenderer dispose method should also be invoked. However, the Overlay
      class does not expose a mechanism to invoke the TextureRenderer dispose. The
      result is a rapid consumption of memory.
      The following snippet shows the basic GLEventListener I used to render the
      overlay in a loop cycle - no actual painting is necessary to consume memory.

      public CustomGLEventListener implements GLEventListener {

      public void display(GLAutoDrawable drawable) {
      Overlay overlay = new Overlay(drawable);
      Graphics2D g = overlay.createGraphics();
      // paint(g); // painting goes here
      g.dispose();

      overlay.drawAll();
      //overlay.dispose(); // Recommended addition
      }

      public void displayChanged(GLAutoDrawable drawable, boolean modeChanged,
      boolean deviceChanged)

      { /* NOOP */ }
      public void init(GLAutoDrawable drawable) { /* NOOP */ }

      public void reshape(GLAutoDrawable drawable, int x, int y, int width, int
      height)

      { /* NOOP */ }

      }

      Adding the following method to the com.sun.opengl.util.j2d.Overlay class and
      invoking it when the overlay is no longer needed appears to resolve the memory
      consumption problem:
      public void dispose() {
      renderer.dispose();
      }

      I expect subsequent calls to the overlay object after dispose is invoked will
      throw a NullPointerException (such as if createGraphics were to be called).

        Activity

        Hide
        kbr added a comment -

        This isn't the recommended usage style for the Overlay. You're supposed to
        create it once in your init() method and use it many times in your display
        callback. See demos.j2d.TestOverlay in the jogl-demos workspace.

        I agree that for completeness a dispose() call should probably be added, but
        this is really more a bug in the application and not in JOGL.

        Show
        kbr added a comment - This isn't the recommended usage style for the Overlay. You're supposed to create it once in your init() method and use it many times in your display callback. See demos.j2d.TestOverlay in the jogl-demos workspace. I agree that for completeness a dispose() call should probably be added, but this is really more a bug in the application and not in JOGL.
        Hide
        jlhider added a comment -

        Understood. The example was simply to demonstrate the condition where if you
        stop using an overlay (and discard it), there is a risk of creeping memory
        consumption. It would not likely be noticed during quick development test runs
        or for short running apps, but could reveal itself in long runs of dynamic apps
        (or in a brutal case such as the example). If during some point in the
        application I want to use one or more overlays (for whatever reason), I should
        be able to release them during the spans of time that they are not needed.

        That's all.
        Thanks

        Show
        jlhider added a comment - Understood. The example was simply to demonstrate the condition where if you stop using an overlay (and discard it), there is a risk of creeping memory consumption. It would not likely be noticed during quick development test runs or for short running apps, but could reveal itself in long runs of dynamic apps (or in a brutal case such as the example). If during some point in the application I want to use one or more overlays (for whatever reason), I should be able to release them during the spans of time that they are not needed. That's all. Thanks

          People

          • Assignee:
            jogl-issues
            Reporter:
            jlhider
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: