CrtDumpMemoryLeaks detecting leaks in string objects

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

CrtDumpMemoryLeaks detecting leaks in string objects

Post by Kiristu »

Hello,

I'm working on detecting memory leaks in my Irrlicht project. Since I'm using Visual C++, I found that I'm supposed to use:

Code: Select all

 
#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>
 
Then:

Code: Select all

 
_CrtDumpMemoryLeaks();
 
To show them when I close my application.

It seems that string (stringc or stringc) allocations imply memory leaks.

I think they are false positive, but how can I eliminate those to see only "real" leaks ?

Thanks
CuteAlien
Admin
Posts: 9923
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: CrtDumpMemoryLeaks detecting leaks in string objects

Post by CuteAlien »

We test with that once in a while. I'm currently not on Windows currently, but are you sure this is an Irrlicht problem and not from your code? Please try it with one of the examples - and also tell which example you used then.
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
zerochen
Posts: 273
Joined: Wed Jan 07, 2009 1:17 am
Location: Germany

Re: CrtDumpMemoryLeaks detecting leaks in string objects

Post by zerochen »

hi,

you can use something like this http://vld.codeplex.com/

or to reduce the false postive you can also add something like this

Code: Select all

 
class A
{
      //do memory staff here
};
int main()
{
      //change the scope 
     {
           A a;
 
 
     } // obj a will be destroyed here
 
     //without the scope change the obj is here still alive
     _CrtDumpMemoryLeaks();
}
 
regards
zerochen

edit: CuteAlien: _CrtDumpMemoryLeaks() will detect static objs so i think its just a false positive one
Kiristu
Posts: 40
Joined: Wed Mar 13, 2013 12:31 am

Re: CrtDumpMemoryLeaks detecting leaks in string objects

Post by Kiristu »

zerochen wrote:you can use something like this http://vld.codeplex.com/
Ho thank you, that was the kind of tool I was looking for and I only found CRT thing until now.

So, of course, with this tool, no more leaks in Irrlicht occur and I can debug mines.

Thanks again
Post Reply