Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Leak Detection in Visual Studio 2008/10

This thread is locked; no one can reply to it. rss feed Print
Leak Detection in Visual Studio 2008/10
Neil Walker
Member #210
April 2000
avatar

Hello,
Just in case anyone hasn't seen it, I found this on the visual studio gallery yesterday:
http://visualstudiogallery.msdn.microsoft.com/7c40a5d8-dd35-4019-a2af-cb1403f5939c

and it works a treat, if anyone's interested. You just stick the include file at the top of your source code, ensure the path can find the library and it does the rest on running the program, outputting to the output and a file.

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

TeaRDoWN
Member #8,518
April 2007
avatar

Nice, I will give it a try. Thanks!

Trent Gamblin
Member #261
April 2000
avatar

Unfortunately (correct me if I'm wrong) these types of leak detectors only detect leaks in your own code, meaning if you do "bitmap = al_load_bitmap("huge.png"); exit(0);" it won't detect it. And for me that's where most of my leaks happen.

I've been playing around with MemoryValidator for a while now. I tried it a year or 2 ago and it was awesome except for lack of symbolicating mingw code. Now I can't seem to get it to symbolicate even MSVC code properly, which is a shame. It does find leaks that nothing else I've tried finds though, and through some telepathic thinking I was able to deduce where the main leaks were coming from without the symbols. If I could get this thing symbolicating my MinGW code, it would be work the $299. It detects memory errors as well as some other things too.

TeaRDoWN
Member #8,518
April 2007
avatar

Shame, however better than nothing I guess.

Previous project I made my own memory tracker that made sure that all allocations were deallocated. Had the wierdest crash/hang there and it was due to a malloc that never got free'd.

Arthur Kalliokoski
Second in Command
February 2005
avatar

And for me that's where most of my leaks happen.

What OS doesn't release memory when a program exits? And it seems to me it'd only be the work of a couple hours to make a wrapper for new or malloc() that'd track memory allocations with a function to list current memory usage, which line of code allocated it, how long it was in existence and you could stick in an atexit() to do it upon exit(0).

[EDIT]

I wrote the above before Teardown edited the previous post, and no, I didn't check his revision history to deduce this :P.

They all watch too much MSNBC... they get ideas.

Trent Gamblin
Member #261
April 2000
avatar

That was an example. I thought it was clear that I meant memory allocated by external libraries isn't tracked by these types of leak detectors (and there are a lot of them). And no, it's not difficult to write one like the one in the OP.

kenmasters1976
Member #8,794
July 2007

You just stick the include file at the top of your source code, ensure the path can find the library and it does the rest on running the program, outputting to the output and a file.

I use memwatch on gcc with MinGW. It works pretty much in the same way although, as Trent Gamblin said, it only detects leaks on your own code. It may not be very robust but it is more than enough for the projects I code and it's proven useful to me.

gnolam
Member #2,030
March 2002
avatar

--
Move to the Democratic People's Republic of Vivendi Universal (formerly known as Sweden) - officially democracy- and privacy-free since 2008-06-18!

TeaRDoWN
Member #8,518
April 2007
avatar

gnolam: Have used that one before, helped me in some places.

The two are fairly similar but the one in the first post seem to have a callstack showing you where in the code where each memory partition was allocated.

EDIT: Got this after installing the "VLD":
1>------ Build started: Project: ****, Configuration: Debug Win32 ------
1>Compiling...
1>****.cpp
1>c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(567) : error C2371: 'BITMAP' : redefinition; different basic types
1> c:\program files (x86)\microsoft visual studio 9.0\vc\include\allegro\gfx.h(262) : see declaration of 'BITMAP'
1>c:\program files\microsoft sdks\windows\v6.0a\include\wingdi.h(3994) : error C2229: struct 'tagDIBSECTION' has an illegal zero-sized array
1>Build log was saved at "file://c:****\Debug\BuildLog.htm"
1>**** - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Does it not work together with Allegro or is there a way to fix this? ::)

SiegeLord
Member #7,827
October 2006
avatar

TeaRDoWN said:

Does it not work together with Allegro or is there a way to fix this? ::)

allegro.cc comes with a nice search feature. This question has been asked and answered tens, if not hundreds of times before.

"For in much wisdom is much grief: and he that increases knowledge increases sorrow."-Ecclesiastes 1:18
[SiegeLord's Abode][Codes]:[DAllegro5]:[RustAllegro]

Edgar Reynaldo
Major Reynaldo
May 2007
avatar

Go to: