JOGL is slowly increasing memory usage! WHY?

Hey folks i have little problem!
Maybe someone has a solution for this.
I have a normal Jogl program which rotates two triangles.
(Sourcecode listed down there)
The problem is that the memory the programm is using slowly increases its value (shown in the windows task-Manager)
Started at 27Mb and after 10 minutes it reaches 80Mb. Any idea?
I have the newest jogl version.
Sorry for that english



import java.awt.*;
import java.awt.event.*;

import net.java.games.jogl.*;

public class AnimJOGLApp
{
	static Animator animator;
	
	public static void main(String[] args)
	{
		Frame frame = new Frame("AnimJOGLApp");
		//Animator für Bewegung
		
		
		//GLCanvas für Anzeige
		GLCanvas canvas = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities());
		canvas.addGLEventListener(new AnimGLEventListener());
		frame.add(canvas);
		
		//Animator mit Zeichenfläche initialisieren
		animator = new Animator(canvas);		

		frame.setSize(	400,
						400);
		frame.addWindowListener(new WindowAdapter()
		{
			public void windowClosing(WindowEvent e)
			{
				animator.stop();
				System.exit(0);
			}
		});

		frame.setVisible(true);
		//Animation starten
		animator.start();
	}
}


import net.java.games.jogl.*;

public class AnimGLEventListener implements GLEventListener
{

	float tri = 0.0f;
	
	
	public void init(GLDrawable drawable)
	{		
	}

	public void display(GLDrawable drawable)
	{
		GL gl = drawable.getGL();
		gl.glMatrixMode(GL.GL_MODELVIEW);
		gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
		gl.glLoadIdentity();
		
		gl.glTranslatef(-0.4f,0.0f,0.0f);
		gl.glRotatef(tri,0.0f,1.0f,0.0f);
		
		gl.glBegin(GL.GL_TRIANGLE_FAN);
		gl.glColor3f(1.0f,0.0f,0.0f);
		gl.glVertex3f(-0.2f,0.0f,0.0f);
		gl.glColor3f(0.0f,1.0f,0.0f);
		gl.glVertex3f(0.2f,0.0f,0.0f);
		gl.glColor3f(0.0f,0.0f,1.0f);
		gl.glVertex3f(0.0f,0.6f,0.0f);
		gl.glEnd();

		gl.glLoadIdentity();
		gl.glTranslatef(0.4f,0.0f,0.0f);
		gl.glRotatef(tri,1.0f,0.0f,0.0f);
		gl.glBegin(GL.GL_TRIANGLE_FAN);
		gl.glColor3f(1.0f,0.0f,0.0f);
		gl.glVertex3f(-0.2f,0.0f,0.0f);
		gl.glColor3f(0.0f,1.0f,0.0f);
		gl.glVertex3f(0.2f,0.0f,0.0f);
		gl.glColor3f(0.0f,0.0f,1.0f);
		gl.glVertex3f(0.0f,0.6f,0.0f);
		gl.glEnd();
		
		if(tri < 360.f)
		tri += 0.5f;
		else
		tri = 0.0f;
	}

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

	}

	public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged)
	{

	}

}

I don’t see a memory leak with your test on my system. What graphics card and driver version are you running with? Have you tried upgrading to the latest driver set from your vendor?

What version of the JDK are you using? Are you running with the system property -Dsun.java2d.noddraw=true (required for correct operation of JOGL on Windows)?

What is the output of java -Dsun.java2d.noddraw=true demos.printext.PrintExt?

HI
tried to use the parameter on my prog but nothing changes.
the memory usage is increasing again.

Its a notebook with a 9700ATI
I’ll try on my desktop and then i write more

My Java-Sys:
JDK 5.0 update 3
jogl 1.1 b12

here is the output of Printext
E:\JOGL Eclipse Workspace\Jingo>C:\Programme\Java\jdk1.5.0_03\bin\java -Dsun.jav
a2d.noddraw=true demos.printext.PrintExt
GL vendor: ATI Technologies Inc.
GL version: 1.5.4454 WinXP Release
GL renderer: MOBILITY RADEON 9700 x86/SSE2
GL extensions:
GL_ARB_multitexture GL_EXT_texture_env_add
GL_EXT_compiled_vertex_array GL_S3_s3tc
GL_ARB_depth_texture GL_ARB_fragment_program
GL_ARB_fragment_program_shadow GL_ARB_fragment_shader
GL_ARB_multisample GL_ARB_occlusion_query
GL_ARB_point_parameters GL_ARB_shader_objects
GL_ARB_shading_language_100 GL_ARB_shadow
GL_ARB_shadow_ambient GL_ARB_texture_border_clamp
GL_ARB_texture_compression GL_ARB_texture_cube_map
GL_ARB_texture_env_add GL_ARB_texture_env_combine
GL_ARB_texture_env_crossbar GL_ARB_texture_env_dot3
GL_ARB_texture_mirrored_repeat GL_ARB_transpose_matrix
GL_ARB_vertex_blend GL_ARB_vertex_buffer_object
GL_ARB_vertex_program GL_ARB_vertex_shader
GL_ARB_window_pos GL_ATI_draw_buffers
GL_ATI_element_array GL_ATI_envmap_bumpmap
GL_ATI_fragment_shader GL_ATI_map_object_buffer
GL_ATI_separate_stencil GL_ATI_texture_env_combine3
GL_ATI_texture_float GL_ATI_texture_mirror_once
GL_ATI_vertex_array_object GL_ATI_vertex_attrib_array_object
GL_ATI_vertex_streams GL_ATIX_texture_env_combine3
GL_ATIX_texture_env_route GL_ATIX_vertex_shader_output_point_siz
e
GL_EXT_abgr GL_EXT_bgra
GL_EXT_blend_color GL_EXT_blend_func_separate
GL_EXT_blend_minmax GL_EXT_blend_subtract
GL_EXT_clip_volume_hint GL_EXT_draw_range_elements
GL_EXT_fog_coord GL_EXT_multi_draw_arrays
GL_EXT_packed_pixels GL_EXT_point_parameters
GL_EXT_rescale_normal GL_EXT_secondary_color
GL_EXT_separate_specular_color GL_EXT_shadow_funcs
GL_EXT_stencil_wrap GL_EXT_texgen_reflection
GL_EXT_texture3D GL_EXT_texture_compression_s3tc
GL_EXT_texture_cube_map GL_EXT_texture_edge_clamp
GL_EXT_texture_env_combine GL_EXT_texture_env_dot3
GL_EXT_texture_filter_anisotropic GL_EXT_texture_lod_bias
GL_EXT_texture_mirror_clamp GL_EXT_texture_object
GL_EXT_texture_rectangle GL_EXT_vertex_array
GL_EXT_vertex_shader GL_HP_occlusion_test
GL_NV_texgen_reflection GL_NV_blend_square
GL_NV_occlusion_query GL_ARB_point_sprite
GL_SGI_color_matrix GL_SGIS_texture_edge_clamp
GL_SGIS_texture_border_clamp GL_SGIS_texture_lod
GL_SGIS_generate_mipmap GL_SGIS_multitexture
GL_SUN_multi_draw_arrays GL_WIN_swap_hint
WGL_EXT_extensions_string WGL_EXT_swap_control

Hi
very strange but on my desktop everything is right even without your extra Param.
maybe my notebook graphic has some problem.
i’ll try the new driver 5.5 from ATI
Thanks for help!

EDIT:
Now i have the new driver. And now its very special.
the memory usage starts at 29,456Mb to 30,1… Mb
then comes GarbageCollector and it has 28,349Mb
now the usage is frequently (every second) increasing by ca 200Kb

And another answer from me!
I try everything Driver(Omega,Ati) earlier java and jogl versions.
Nothing helped solving this problem.

IMHO i would say that there is a bug with the ATI Mobility.
When someone of the developer in the jogl-dev read this.
Test those things please

Could you please try a test build of JOGL for me? It should be downloadable with this link, or go to the JOGL home page, then to Documents and Files, then to Temporary Files. This is a Win32 build of the current JOGL source tree, which worked around a different memory leak than yours in ATI’s drivers on Windows. I’d like to know whether it addresses the memory leak you’re seeing.

Does the simple Gears demo leak memory too?

Thats very nice of you!
But I’m sorry to tell that this didn’t solve the problem.
All i can say that the memory usage is now increasing by 4 Kb and don’t stop.
There must be something else.

Is there someone who has got an ATI 9700 Mobility too, who can test this twice!

Have you tried using GL_TRIANGLES instead of GL_TRIANGLE_FAN? Maybe there’s a bug in ATI’s drivers specific to the use of triangle fans.

GL_TRIANGLES and GL_TRIANGLE_FAN is the same.
Tried the new driver from ATI 5.6 (new today), the only effect
i can see is that the memory usage is smaller at the start
before 27Mb after 25Mb but is increasing too

seems to be very difficult

Could you try this LWJGL port of your test and see if it performs any differently? You’ll need to download the latest version of LWJGL and put lwjgl.jar in your CLASSPATH and have the directory containing lwjgl.dll in your PATH.

Also, does the JOGL Gears demo leak memory on your machine?


import java.awt.*;
import java.awt.event.*;
import java.nio.*;
import java.util.*;
import javax.swing.*;

import org.lwjgl.*;
import org.lwjgl.opengl.*;

/** A simple demonstration exercising context creation and destruction
    as a GLCanvas is added to and removed from its parent container. */

public class AnimLWJGLApp {

  static class MyCanvas extends AWTGLCanvas {
    float tri = 0.0f;

    public MyCanvas() throws LWJGLException {
      super();
    }

    public void paintGL() {
      GL11.glMatrixMode(GL11.GL_MODELVIEW);
      GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
      GL11.glLoadIdentity();

      GL11.glTranslatef(-0.4f,0.0f,0.0f);
      GL11.glRotatef(tri,0.0f,1.0f,0.0f);

      GL11.glBegin(GL11.GL_TRIANGLE_FAN);
      GL11.glColor3f(1.0f,0.0f,0.0f);
      GL11.glVertex3f(-0.2f,0.0f,0.0f);
      GL11.glColor3f(0.0f,1.0f,0.0f);
      GL11.glVertex3f(0.2f,0.0f,0.0f);
      GL11.glColor3f(0.0f,0.0f,1.0f);
      GL11.glVertex3f(0.0f,0.6f,0.0f);
      GL11.glEnd();

      GL11.glLoadIdentity();
      GL11.glTranslatef(0.4f,0.0f,0.0f);
      GL11.glRotatef(tri,1.0f,0.0f,0.0f);
      GL11.glBegin(GL11.GL_TRIANGLE_FAN);
      GL11.glColor3f(1.0f,0.0f,0.0f);
      GL11.glVertex3f(-0.2f,0.0f,0.0f);
      GL11.glColor3f(0.0f,1.0f,0.0f);
      GL11.glVertex3f(0.2f,0.0f,0.0f);
      GL11.glColor3f(0.0f,0.0f,1.0f);
      GL11.glVertex3f(0.0f,0.6f,0.0f);
      GL11.glEnd();

      if(tri < 360.f)
        tri += 0.5f;
      else
        tri = 0.0f;

      try {
        swapBuffers();
      } catch (LWJGLException e) {
        e.printStackTrace();
      }
    }
  }

  public static void main(String[] args) throws LWJGLException
  {
    Frame frame = new Frame("AnimLWJGLApp");

    //GLCanvas für Anzeige
    final MyCanvas canvas = new MyCanvas();
    frame.add(canvas);

    frame.setSize( 400,
                   400);
    frame.addWindowListener(new WindowAdapter()
      {
        public void windowClosing(WindowEvent e)
        {
          System.exit(0);
        }
      });

    frame.setVisible(true);
    //Animation starten
    while (true) {
      try {
        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
              canvas.paint(null);
            }
          });
      } catch (Exception e) {
        e.printStackTrace();
      }
    }
  }
}

Hey news for you.
This code is doing right.
NO Increasing!
Do you know what the problem can be?

EDIT: Tested a bit more! It is a increasing too.
But not very fast! The program is running for 10 Minutes now without any keytyping or mousemoving!
Memory usage before 18600Kb and after 18616. You see not very much and i think it stops there!
And when i move the mouse over the canvas its increasing much faster but this i think is another problem!

I’ll have to look more deeply at JOGL’s and LWJGL’s context creation and handling code and see if I can figure out any essential differences.

That is much work i think.
Wish u good luck for this.

Another info:
When i deactivate the Animator and don’t do anything, there is no leak.
But when i move the mouse or do anything else which initiate a refresh of GLCanvas
then i i have the same problem.

Hope this helps a bit!

I’ve been able to reproduce your problem on a co-worker’s laptop with an ATI Mobility Radeon 9700. Through trial and error I found that specifying -Djogl.1thread=false works around the memory leak. Does this work for you?

I’m going to continue looking into the root cause of this bug.

Yeah! Great! It does it!
How you found it out?
Thanks for that. Now i can go back to develop my engine!
Hope you find the root of theevil leak

EDIT: One thing…
is it right when i use this -Djogl.1thread=false
that moving the window is not very smooth.
When i move it it needs 3-5 seconds to rebuild itself and the animation stops during this too!

Yes, the hanging behavior is due to other bugs in ATI’s drivers that the single-thread workaround was originally designed to address. It may take a little while to track down exactly what is causing the memory leak but I hope the workaround will be enough to get you going for the time being.

I’ve tracked down the root cause of this memory leak to a bug in ATI’s OpenGL drivers which seems to only occur on this particular mobile graphics chip (or maybe similar ones, but definitely not in their desktop chips or in much earlier mobile chips). JOGL Issue 166 documents the bug and its root cause and provides a workaround. The JOGL User’s Guide has also been updated with the workaround. The workaround will be available in the next build of JOGL.