Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.
Moderator: Coders of Rage
dandymcgee
ES Beta Backer
Posts: 4709 Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:
Post
by dandymcgee » Sun Jan 06, 2013 8:16 pm
Visual Leak Detector
http://vld.codeplex.com/
Literally the easiest thing I've ever used. You reference the lib, include the header and when you exit the application it spits a memory allocation report to the Output window.
When it detects an allocation that was never freed it gives you the call stack at the time of allocation, which includes the file name and line number. For example:
Call Stack:
spritesheet.cpp (29): ProjectGenesis.exe!Spritesheet::Spritesheet + 0x7 bytes
renderengine.cpp (129): ProjectGenesis.exe!RenderEngine::LoadSpritesheetCB + 0x42 bytes
sqlite3.c (90614): ProjectGenesis.exe!sqlite3_exec + 0x15 bytes
renderengine.cpp (143): ProjectGenesis.exe!RenderEngine::LoadSpritesheet + 0x1C bytes
level.cpp (53): ProjectGenesis.exe!Level::Level + 0x12 bytes
gameengine.cpp (189): ProjectGenesis.exe!GameEngine::LoadLevel + 0x2F bytes
main.cpp (83): ProjectGenesis.exe!main + 0x26 bytes
I look at line 29 in Spritesheet.cpp and find:
frameRect = new sf::IntRect();
I add the cleanup code I forgot in Spritesheet::~Spritesheet():
delete frameRect;
No more memory leak.
Falco Girgis wrote: It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!
eatcomics
ES Beta Backer
Posts: 2528 Joined: Sat Mar 08, 2008 7:52 pm
Location: Illinois
Post
by eatcomics » Mon Jan 07, 2013 3:32 pm
Wow, that is probably one of the coolest things I've ever seen. Thanks.
MarauderIIC
Respected Programmer
Posts: 3406 Joined: Sat Jul 10, 2004 3:05 pm
Location: Maryland, USA
Post
by MarauderIIC » Wed Jan 09, 2013 10:27 am
For those of you on Linux, a popular tool (probably not as easy) is valgrind (val-grihnd, not val-grynd).
http://valgrind.org/
I realized the moment I fell into the fissure that the book would not be destroyed as I had planned.
dandymcgee
ES Beta Backer
Posts: 4709 Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:
Post
by dandymcgee » Wed Jan 09, 2013 12:46 pm
MarauderIIC wrote: For those of you on Linux, a popular tool (probably not as easy) is valgrind (val-grihnd, not val-grynd).
http://valgrind.org/
I've seen so many people worship that tool, and it's been around for ages. If only someone made something comparable for Windows.
Falco Girgis wrote: It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches!