Compiler flag memory leak?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Mr. Moxie
Posts: 48
Joined: Thu Dec 06, 2007 7:55 pm
Contact:

Compiler flag memory leak?

Post by Mr. Moxie »

The blue space is a missing block, and it's making me crazy. It's either a memory corruption on my end or I'm setting the compiler flags in vc2005 incorrectly.

When running in a debug build its fine, and when I run a release its missing tiles. From what I can tell, is that

Code: Select all

video::ITexture		*m_pGfx;
has been corrupted somehow. I render the tiles like so.

Code: Select all

	if(!m_pAnimNode)
	{
		GAME->GetDriver()->draw2DImage(	m_pGfx, 
									core::position2d<s32>(m_iPosX,m_iPosY),	
									core::rect<s32>(0,0,m_pGfx->getSize().Width,m_pGfx->getSize().Height),
									NULL,
									video::SColor(255,255,255,255),
									m_TileSpec.m_bChroma);
	}
	else
	{
		m_pAnimNode->Update();
	}
Should I be using /MD instead of /MT? Other compiler settings?

Image
George A Lancaster
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

While I certainly can't tell without the source, I doubt it's caused by compiler flags. The most common reason for different behavior in release are probably uninitialized variables.

Using /MD is OK for release.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mr. Moxie
Posts: 48
Joined: Thu Dec 06, 2007 7:55 pm
Contact:

Post by Mr. Moxie »

It's probably un-initialized variables. Just wanted to make sure there wasn't some sort of easy flag fix I didn't read about.

I did a Beta build (some debugging info), but still couldn't find it. Any time I run it using 2005 under any debug the problem goes away. It's making me crazy, and is really holding up my project.
George A Lancaster
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Yeah, heisenbugs are ugly :-(. Try to isolate it by removing/outcommenting as much as possible. Or even write a new test-application just with the critical routine, that often helps.

Good luck.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mr. Moxie
Posts: 48
Joined: Thu Dec 06, 2007 7:55 pm
Contact:

Post by Mr. Moxie »

My blue guys have a strange black halo on their border, and it's not in the graphic file. Is this a sign of something?

Just grasping at straws. :evil:
George A Lancaster
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

If it's just on the outer pixel or the rectangle then there could be some one-off error at one place. For example you have to careful as rects are using units and not pixels.

If you have GNU/Linux try running your application within valgrind. That can find a lot of runtime errors which are caused by invalid memory accesses. Similar you can enable some runtime-checks within VS somehow.

Also it might help compiling your application using the highest warning level. And fixing all warnings within your code.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mr. Moxie
Posts: 48
Joined: Thu Dec 06, 2007 7:55 pm
Contact:

Post by Mr. Moxie »

Thanx for the info. Rectangles use units. Units of what?

I tried setting my warning level in VC but it only complained about irrlicht includes.

Here is another screen shot of my game messing up:

Image
George A Lancaster
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Mr. Moxie wrote:Thanx for the info. Rectangles use units. Units of what?
Units of pixels. Example: If you have a image consisting of a single pixel the rect will go from 0,0 to 1,1 because it's one unit wide in both directions. If it were given as pixelcoordinates (which it isn't) instead of units it would be from 1,1 to 1,1. I just mention it as it's something which tripped me once before I knew that.

Mr. Moxie wrote: Here is another screen shot of my game messing up:
Can't help as it's not obvious what you are doing - that could be caused by anything. For example it could be simply a texture repeating because you told it not to scale and project it on a rectangle which is larger than the image. Give us a codeexample if you want concrete help.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Mr. Moxie
Posts: 48
Joined: Thu Dec 06, 2007 7:55 pm
Contact:

Post by Mr. Moxie »

Part of my previous problem is a power of two issue with my graphics. So I was going to simply use the appropriate rect structs to get the region I want, but I've found that I'm getting a translucent edge on the upper right corner when doing a simple test?

Code: Select all

		GAME->GetDriver()->draw2DImage(m_pGfx,
							core::rect<s32>(m_iPosX,m_iPosY,m_pGfx->getSize().Width+m_iPosX,m_pGfx->getSize().Height+m_iPosY),
							core::rect<s32>(0,0,(s32)m_pGfx->getSize().Width,(s32)m_pGfx->getSize().Height),
							NULL,
							&video::SColor(255,255,255,255),
							m_TileSpec.m_bChroma);    
Image[/code]
George A Lancaster
Mr. Moxie
Posts: 48
Joined: Thu Dec 06, 2007 7:55 pm
Contact:

Post by Mr. Moxie »

Stopped the translucent corners by setting the SColor arg to NULL. Now if I could only find my missing tiles. :roll:

Code: Select all

		GAME->GetDriver()->draw2DImage(m_pGfx,
							core::rect<s32>(m_iPosX,m_iPosY,m_pGfx->getOriginalSize().Width+m_iPosX,m_pGfx->getOriginalSize().Height+m_iPosY),
							core::rect<s32>(0,0,m_pGfx->getOriginalSize().Width,m_pGfx->getOriginalSize().Height),
							NULL,
							NULL,
							m_TileSpec.m_bChroma);   
George A Lancaster
Mr. Moxie
Posts: 48
Joined: Thu Dec 06, 2007 7:55 pm
Contact:

Post by Mr. Moxie »

My missing tiles were my fault. I never set my own gmTile classes' member variable to true.

Code: Select all

m_bActive			=true; 
:oops:

Thanx for the help though "Cute Alien". It helped me find the power of 2 texture bug and pushed me to find my own screw up.
George A Lancaster
Post Reply