std::vector memory leak issues

Started by
11 comments, last by Crusable77 10 years, 6 months ago

In the future use vld2 as it will extend the VS2012 memory leak tracker with proper callstacks, this makes it a lot easier to track where your leaks are coming from.

Your leaks will look more like this:



---------- Block 1199 at 0x04BE1058: 136 bytes ----------
Call Stack:
d:\Foobar\FooLog.cpp (26): FooLog::getInstance
d:\Foobar\FooMain.cpp (75): FooMain::init
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (578): __tmainCRTStartup
f:\dd\vctools\crt_bld\self_x86\crt\src\crtexe.c (403): WinMainCRTStartup
0x759A3677 (File and line number not available): BaseThreadInitThunk
0x770C9D42 (File and line number not available): RtlInitializeExceptionChain
0x770C9D15 (File and line number not available): RtlInitializeExceptionChain
Data:
9C 33 2D 6B 74 2A 2D 6B C8 11 BE 04 00 00 00 00 .3-kt*-k ........
00 00 00 00 70 14 BB 6C 70 14 BB 6C 00 00 00 00 ....p..l p..l....
00 00 00 00 68 14 BB 6C 68 14 BB 6C 00 00 00 00 ....h..l h..l....
00 00 00 00 6C 14 BB 6C 6C 14 BB 6C 20 12 BE 04 ....l..l l..l....
00 00 00 00 CD 00 CD CD 00 00 00 00 01 CD CD CD ........ ........
68 14 BB 6C 78 33 2D 6B 00 00 00 00 00 00 00 00 h..lx3-k ........
00 00 00 00 01 02 00 00 06 00 00 00 00 00 00 00 ........ ........
00 00 00 00 00 00 00 00 88 11 BE 04 5C 10 BE 04 ........ ....\...
00 00 00 00 20 CD CD CD ........ ........

The output lines are double click able to jump to the actual allocation, and instead of the define all you need to do is include vld.h somewhere, point to the lib and include dir and all is done, in release vld will not compile with your project so no need for markers around the header.

Worked on titles: CMR:DiRT2, DiRT 3, DiRT: Showdown, GRID 2, theHunter, theHunter: Primal, Mad Max, Watch Dogs: Legion

Advertisement

Here's something else you can do: Reduce your program to the simplest possible program that still shows a leak. Just make a copy of your code and start taking out anything that doesn't have to do with the problem at hand. You'll get to a point where anything you remove will stop showing the problem. We'll call that a "minimal program".

In the process of finding that minimal program, you'll very often figure out the problem yourself. And if you don't, you can always post the program here (it shouldn't be more than 40 lines) and you'll get much better help.

This is a general procedure that works for many types of bugs.

Thank you everyone. I figured out the error was with my singleton, it wasn't deleting properly. Thanks for the help.

This topic is closed to new replies.

Advertisement