diff options
author | Kenneth Russel <kbrussel@alum.mit.edu> | 2005-06-22 08:05:55 +0000 |
---|---|---|
committer | Kenneth Russel <kbrussel@alum.mit.edu> | 2005-06-22 08:05:55 +0000 |
commit | e9b806b277428b74a51afb5e076afe7dfabb26d4 (patch) | |
tree | 779d537277a577c7fb8161ed4013a88026933eb0 | |
parent | 9cf58f1f404b069ab3f13f80daa774b7da4ff8e2 (diff) |
Fixed Issue 166: Memory leak with ATI Mobility Radeon 9700
Worked around memory leak in ATI's OpenGL drivers by adding system
property -Djogl.GLContext.nofree which users can specify on the
command line. There is no good general-purpose workaround for this bug
which works well on all hardware and in all kinds of applications.
Issues may remain if this workaround is used and if the GLCanvas is
removed and re-added to its parent container. Use at your own risk.
Also cleaned up Windows ChoosePixelFormat code path; made sure
PIXELFORMATDESCRIPTOR was completely filled out.
git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/trunk@306 232f8b59-042b-4e1e-8c03-345bb8c30851
-rw-r--r-- | doc/userguide/index.html | 19 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/GLContext.java | 1 | ||||
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsGLContext.java | 43 |
3 files changed, 52 insertions, 11 deletions
diff --git a/doc/userguide/index.html b/doc/userguide/index.html index 1ef37540b..03880cbd4 100644 --- a/doc/userguide/index.html +++ b/doc/userguide/index.html @@ -549,6 +549,25 @@ future JOGL release and plan to have better interoperability by the time JDK 6.0 is shipped. </P> +<P> + +There is a serious memory leak in ATI's OpenGL drivers which is +exhibited on Windows XP on Mobility Radeon 9700 hardware. It's +possible it will be present on other hardware as well though it was +not reproducible at the time of this writing on desktop Radeon +hardware or older ATI mobile chips. The bug is documented in <A +HREF="https://jogl.dev.java.net/issues/show_bug.cgi?id=166">JOGL Issue +166</A> and a bug has been filed with ATI. You can confirm the +presence of the bug either with the test case in that bug report or by +simply running the Gears demo; if the process size grows over time in +the Task Manager, the memory leak is present on your hardware. For the +time being, you can work around this memory leak by specifying the +system property <CODE>-Djogl.GLContext.nofree</CODE> on the command +line when launching your JOGL applications. There is no good +general-purpose workaround for this bug which behaves well on all +hardware. + +</P> <H3> Solaris, Linux (X11 platforms) </H3> diff --git a/src/net/java/games/jogl/impl/GLContext.java b/src/net/java/games/jogl/impl/GLContext.java index 0e20a5691..a70b195ac 100644 --- a/src/net/java/games/jogl/impl/GLContext.java +++ b/src/net/java/games/jogl/impl/GLContext.java @@ -46,6 +46,7 @@ import net.java.games.gluegen.runtime.*; public abstract class GLContext { protected static final boolean DEBUG = Debug.debug("GLContext"); protected static final boolean VERBOSE = Debug.verbose(); + protected static final boolean NO_FREE = Debug.isPropertyDefined("jogl.GLContext.nofree"); static { NativeLibLoader.load(); diff --git a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java index d808634f2..f597d56b7 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsGLContext.java +++ b/src/net/java/games/jogl/impl/windows/WindowsGLContext.java @@ -140,12 +140,24 @@ public abstract class WindowsGLContext extends GLContext { created = true; } - if (!WGL.wglMakeCurrent(hdc, hglrc)) { - throw new GLException("Error making context current: " + WGL.GetLastError()); - } else { - if (DEBUG && VERBOSE) { - System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + hdcToString(hdc) + - ", hglrc " + hdcToString(hglrc) + ") succeeded"); + boolean skipMakeCurrent = false; + if (NO_FREE) { + if (WGL.wglGetCurrentContext() == hglrc) { + if (DEBUG && VERBOSE) { + System.err.println(getThreadName() + ": skipping wglMakeCurrent because context already current"); + } + skipMakeCurrent = true; + } + } + + if (!skipMakeCurrent) { + if (!WGL.wglMakeCurrent(hdc, hglrc)) { + throw new GLException("Error making context current: " + WGL.GetLastError()); + } else { + if (DEBUG && VERBOSE) { + System.err.println(getThreadName() + ": wglMakeCurrent(hdc " + hdcToString(hdc) + + ", hglrc " + hdcToString(hglrc) + ") succeeded"); + } } } @@ -174,8 +186,10 @@ public abstract class WindowsGLContext extends GLContext { } protected synchronized void free() throws GLException { - if (!WGL.wglMakeCurrent(0, 0)) { - throw new GLException("Error freeing OpenGL context: " + WGL.GetLastError()); + if (!NO_FREE) { + if (!WGL.wglMakeCurrent(0, 0)) { + throw new GLException("Error freeing OpenGL context: " + WGL.GetLastError()); + } } } @@ -550,9 +564,6 @@ public abstract class WindowsGLContext extends GLContext { WGL.PFD_GENERIC_ACCELERATED); if (caps.getDoubleBuffered()) { pfdFlags |= WGL.PFD_DOUBLEBUFFER; - if (onscreen) { - pfdFlags |= WGL.PFD_SWAP_EXCHANGE; - } } if (onscreen) { pfdFlags |= WGL.PFD_DRAW_TO_WINDOW; @@ -565,7 +576,17 @@ public abstract class WindowsGLContext extends GLContext { pfd.cRedBits ((byte) caps.getRedBits()); pfd.cGreenBits((byte) caps.getGreenBits()); pfd.cBlueBits ((byte) caps.getBlueBits()); + pfd.cAlphaBits((byte) caps.getAlphaBits()); + int accumDepth = (caps.getAccumRedBits() + + caps.getAccumGreenBits() + + caps.getAccumBlueBits()); + pfd.cAccumBits ((byte) accumDepth); + pfd.cAccumRedBits ((byte) caps.getAccumRedBits()); + pfd.cAccumGreenBits((byte) caps.getAccumGreenBits()); + pfd.cAccumBlueBits ((byte) caps.getAccumBlueBits()); + pfd.cAccumAlphaBits((byte) caps.getAccumAlphaBits()); pfd.cDepthBits((byte) caps.getDepthBits()); + pfd.cStencilBits((byte) caps.getStencilBits()); pfd.iLayerType((byte) WGL.PFD_MAIN_PLANE); return pfd; } |