_Crt*()-Heapfunktionen -> falsche Ausgabe



  • Hi,

    eigentlich wollte ich hiermit alle Memory Leaks, also Speicher, der allokiert, aber nicht wieder freigegeben wurde, rausfinden:

    HeapDebugger.h:

    #ifndef THETAENGINEINCLUDE_HEAPDEBUG
    #define THETAENGINEINCLUDE_HEAPDEBUG
    
    #include <crtdbg.h>
    #include "Global.h"
    
    class thetaHeapDebugger
    {
    public:
        THETADLL thetaHeapDebugger();
        THETADLL ~thetaHeapDebugger();
    
    protected:
        _CrtMemState m_crtCheckpoint;
    };
    
    #endif
    

    HeapDebugger.cpp:

    #include <crtdbg.h>
    #include "HeapDebug.h"
    
    thetaHeapDebugger::thetaHeapDebugger()
    {
        _CrtMemCheckpoint(&m_crtCheckpoint);
    }
    
    thetaHeapDebugger::~thetaHeapDebugger()
    {
        _CrtMemState crtCheckpoint2, crtDifference;
        _CrtMemCheckpoint(&crtCheckpoint2);
        _CrtMemDifference(&crtDifference, &m_crtCheckpoint, &crtDifference);
        _CrtMemDumpStatistics(&crtDifference);
        _CrtMemDumpAllObjectsSince(&crtDifference);
    }
    

    Ganz am Anfang des Programms wird eine Instanz von dieser Klasse erstellt und ganz am Ende wieder gelöscht.

    Als Ausgabe im Debugfenster erhalte ich aber:

    -858993460 bytes in -858993460 Free Blocks.
    -858993585 bytes in -858993463 Normal Blocks.
    -858999094 bytes in -858993502 CRT Blocks.
    -858993460 bytes in -858993460 Ignore Blocks.
    -858993460 bytes in -858993460 Client Blocks.
    Largest number used: -858999219 bytes.
    Total allocations: -859000597 bytes.
    Dumping objects ->
    {49} normal block at 0x008A1FC0, 52 bytes long.
    Data: < * > A0 1F 8A 00 00 00 00 00 03 00 00 00 2A 00 00 00
    {44} normal block at 0x008A1EC0, 33 bytes long.
    Data: < C > 00 43 00 CD CD CD CD CD CD CD CD CD CD CD CD CD
    {43} normal block at 0x008A1F10, 40 bytes long.
    Data: < |L > 14 7C 4C 10 16 00 00 00 00 00 00 00 00 00 00 00
    Object dump complete.

    Das kann ja irgendwie nicht sein (also ein Programm, das -858MB RAM verbraucht, wollte ich eigentlich nicht schreiben 😃 ), oder?

    Wo ist der Fehler?

    ChrisM



  • Hat sich geklärt, ich verwende jetzt direkt _CrtDumpMemoryLeaks()

    ChrisM


Anmelden zum Antworten