• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 921
  • Last Modified:

Tao Framework: Memory leak involving Gl.glGenTextures

A customer is using the Tao Framework for 3D rendering in a business application.

Since we converted our code from .Net 1.1 to .Net 3.5, we are experiencing a memory leak.  Every time we render, memory usage increases approximately 3 MB.

The offending line of code seems to be:
Gl::glGenTextures(1, texIndex);

Open in new window


According to what we can see in Visual Studio, texIndex is initialized as IntPtr::0 and, within the code to which we have visibility, it never changes ... which seems weird.

How can we recover that memory that the glGenTextures call allocates?

Thanks for any help on this!
0
Daniel Wilson
Asked:
Daniel Wilson
  • 3
  • 3
1 Solution
 
satsumoSoftware DeveloperCommented:
glGenTextures allocates texture ID's, not actually textures, the ID's are just integers.  Though OpenGL may be allocating some memory to track the state of the texture identified by that ID.

You can free the ID by calling glDeleteTextures with a pointer to the ID that was generated.

However 3MB is too much for the ID to be the problem.  The memory is probably being wasted by a texture that is loaded into that ID.  The program may be calling glTexImage2D with the new ID every frame.

If you have a texture that changes every frame, then call glTexImage2D with the same ID, only allocate the ID once.  If the texture does not change then allocate the ID and call glTexImage2D once, before rendering begins.
0
 
satsumoSoftware DeveloperCommented:
Oh and Hello DanielWilson, always like answering question from other experts.

I'm not sure about the IntPtr::0 thing either.  glGenTextures takes a pointer to an int and writes the ID into the int before returning.  I would imagine setting the pointer to zero would be an error.  Might even cause an exception if the implementation didn't handle it.  I haven't used IntPtr so I don't know if that is pointing to zero or initialising the pointed integer to zero.
0
 
Daniel WilsonAuthor Commented:
Thanks, satsumo.  I implemented that today & will check it out tomorrow.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
Daniel WilsonAuthor Commented:
My implementation failed ... but I'm sure you're on the right track w/ glDeleteTextures.  Some garbage collection of some of the other objects has caused the memory usage to stay a lot more sane than it was a couple weeks ago!

Thanks for the help.
0
 
satsumoSoftware DeveloperCommented:
I didn't consider the Java end of the problem.  OpenGL doesn't use garbage collection, perhaps the Java implementation changes that.  Thanks for the points.
0
 
Daniel WilsonAuthor Commented:
Sorry ... meant .Net garbage collection!
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now