[iMiniB3D] Matrix::Inverse() mem leak

BlitzMax Forums/MiniB3D Module/[iMiniB3D] Matrix::Inverse() mem leak

Leto(Posted 2010) [#1]
Hi guys, I'm playing around with iMiniB3D 0.4 and ran XCode Instruments for leaks. I'm seeing a lot of leaks in Matrix::Inverse()

It's called by Camera::Update() - camera.mm line 511:

Matrix* new_mat=mat.Inverse();


the Inverse function itself runs the following in matrix.h line 107:

Matrix* mat=new Matrix;


but in neither Camera nor Matrix does it appear to be released. Would someone be able to suggest what can be done to resolve this?

Thanks!


ima747(Posted 2010) [#2]
I recall fixing this previously but I cant recall what I posted its under...

you want to put
delete new_mat;
in camera.mm at about 535 so it looks like

...
	mod_mat[14]=new_mat->grid[3][2];
	mod_mat[15]=new_mat->grid[3][3];
	
	delete new_mat;
	
	glGetFloatv(GL_PROJECTION_MATRIX,&proj_mat[0]);


new_mat is used to hold the inverted matrix from the camera, then overloaded with the currently active matrix, which is then copied into mod_mat at which point new_mat is no longer needed. I don't know why everything isn't just loaded into mod_mat up (just delete mod_mat, then using it in place of new_mat for the inverse and loadmatrix...) but I don't have the time to question something that works at the moment :0) I'm guessing simon has his reasons.

Last edited 2010

Last edited 2010


Leto(Posted 2010) [#3]
I wasn't sure it would be that easy. Thanks, ima747!