KindDragon / vld

Visual Leak Detector for Visual C++ 2008-2015
https://kinddragon.github.io/vld/
GNU Lesser General Public License v2.1
1.01k stars 314 forks source link

Not showing file name and line number in leak dump #42

Closed Saftur closed 6 years ago

Saftur commented 6 years ago

I've been having this issue where VLD doesn't tell me file names and line numbers in the call stack. main.cpp:

#include <iostream>

#include <vld.h>
/*#define _CRTDBG_MAP_ALLOC
#include <stdlib.h>
#include <crtdbg.h>*/

#include "engine.h"
#include "levelmanager.h"
#include "opengl.h"

int main(int argc, char *argv[]) {
    if (!Engine::init(&argc, argv))
        return 1;

    int *i = new int();

    //Engine::getLevelManager()->load("Level1");

    glutMainLoop();

    Engine::shutdown();
    //_CrtDumpMemoryLeaks();

    return 0;
}

Output:

---------- Block 5 at 0x065FD190: 4 bytes ----------
  Leak Hash: 0x2CDE864B, Count: 1, Total 4 bytes
  Call Stack (TID 13128):
    ucrtbased.dll!malloc()
    GameProject.exe!0x00398C1D()
    GameProject.exe!0x0033B2D2()
    GameProject.exe!0x0039A43E()
    GameProject.exe!0x0039A2E0()
    GameProject.exe!0x0039A17D()
    GameProject.exe!0x0039A4B8()
    KERNEL32.DLL!BaseThreadInitThunk() + 0x24 bytes
    ntdll.dll!RtlGetAppContainerNamedObjectPath() + 0x137 bytes
    ntdll.dll!RtlGetAppContainerNamedObjectPath() + 0x107 bytes
  Data:
    00 00 00 00                                                  ........ ........

The main.cpp has a new int() which is never deleted, and since it's right in the main.cpp, it shouldn't be going through external dlls or some-such, and all of the memory leaks I can see show up like above.

Saftur commented 6 years ago

I found a solution to this. Go into 'Project Settings->Linker->Debugging->Generate Debug Info' and change that setting to "Generate Debug Information optimized for sharing and publishing (/DEBUG:FULL)"