OpenGL / DevIL

Started by
9 comments, last by KuJi 16 years ago
I think i've stumbled upon a memory leak (or im not freeing the resource correctly..) The memory problem occurs here:

	ILuint ilTexture;
	ilGenImages(1, &ilTexture);
	ilBindImage(ilTexture);

	if (ilLoadImage(path))
	{
		// nothing here -- just testing
	}

	ilDeleteImages(1, &ilTexture);
One thing you need to understand is that calling ilLoadImage (without generating / binding the texture) won't cause this. This is the minimum I came up with to reproduce the memory leak. Does this occur to anyone else? Am I not freeing it correctly? :(
Advertisement
I'm no expert but I'm presuming each of those function provides a return value for a failure?

Try doing a IlBindImage(0) or equivalent for unbinding the texture and see if the problem still occurs. But no, if the code produces a texture fine in the generate texture phase you shouldn't have that problem.

Also how big a memory leak are you talking about and how are you tracking it?

Jamie
The current image is not deleted until it is unbound (i.e. either zero or another image is bound). That may show up as a temporary memory leak, but you need to be more specific about this leak.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by swiftcoder
The current image is not deleted until it is unbound (i.e. either zero or another image is bound). That may show up as a temporary memory leak, but you need to be more specific about this leak.


I've waited about 2-5 minutes and nothing has shown to fix this. Problem is, when using SDL and resizing -- I went to go use the function to reload all the graphics back to opengl, and noticed this.

Quote:Original post by Neutrinohunter
I'm no expert but I'm presuming each of those function provides a return value for a failure?

Try doing a IlBindImage(0) or equivalent for unbinding the texture and see if the problem still occurs. But no, if the code produces a texture fine in the generate texture phase you shouldn't have that problem.

Also how big a memory leak are you talking about and how are you tracking it?

Jamie


I watch it via control-alt-delete when resizing. And I'll try that.

*Edit* No, it still occurs -- and depending on how many graphics were loaded, it could be a couple mb per resize.
Quote:Original post by KuJi
I watch it via control-alt-delete when resizing. And I'll try that.

*Edit* No, it still occurs -- and depending on how many graphics were loaded, it could be a couple mb per resize.


You mean the task manager? That`s not a good way to know if there is a leak or not. The compiler will tell you if you have a leak or you need to use a 3rd party tool.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);
Quote:Original post by V-man
You mean the task manager? That`s not a good way to know if there is a leak or not. The compiler will tell you if you have a leak or you need to use a 3rd party tool.


Well seeing the memory climb 20 mb because the game is resized is definitely a problem <.<.
I agree with V-Man, its the not best way but one can generally acertain massive leaks in a program with a Task Manager. I once got my code to go up to around 500,000k within Windows then crash the OS when I forgot to clear something up so it is possible to track with it.

I generally error on the side of its your code unless proven otherwise, even though recently I have proved various bugs within the QT rendering library.

Post the whole source so one of us can compile it, there could be a million different reasons for the problem.

Neutrinohunter
Did you called ilInit() before creating image?
I'll draw some code up that requires sdl / openil to show the bug shortly.. just going to throw it in one file though so :(
Every resize consumes 20MB?
It would be weird if DevIL had an obvious bug. I`ve been using it for a long time.
Sig: http://glhlib.sourceforge.net
an open source GLU replacement library. Much more modern than GLU.
float matrix[16], inverse_matrix[16];
glhLoadIdentityf2(matrix);
glhTranslatef2(matrix, 0.0, 0.0, 5.0);
glhRotateAboutXf2(matrix, angleInRadians);
glhScalef2(matrix, 1.0, 1.0, -1.0);
glhQuickInvertMatrixf2(matrix, inverse_matrix);
glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

This topic is closed to new replies.

Advertisement