Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 831785
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T04:15:43+00:00 2026-05-15T04:15:43+00:00

I want to find memory leaks in my application using standard utilities. Previously I

  • 0

I want to find memory leaks in my application using standard utilities.
Previously I used my own memory allocator, but other people (yes, you AlienFluid) suggested to use Microsoft’s Application Verifier, but I can’t seem to get it to report my leaks.
I have the following simple application:

#include <iostream>
#include <conio.h>

class X
   {
   public:
      X::X() : m_value(123) {}
   private:
      int m_value;
   };

void main()
{
X *p1 = 0;
X *p2 = 0;
X *p3 = 0;

p1 = new X();
p2 = new X();
p3 = new X();
delete p1;
delete p3;
}

This test clearly contains a memory leak: p2 is new’d but not deleted.

I build the executable using the following command lines:

cl /c /EHsc /Zi /Od /MDd test.cpp
link /debug test.obj

I downloaded Application Verifier (4.0.0665) and enabled all checks.

If I now run my test application I can see a log of it in Application Verifier, but I don’t see the memory leak.

Questions:

  • Why doesn’t Application Verifier report a leak?
  • Or isn’t Application Verifier really intended to find leaks?
  • If it isn’t which other tools are available to clearly report leaks at the end of the application (i.e. not by taking regular snapshots and comparing them since this is not possible in an application taking 1GB or more), including the call stack of the place of allocation (so not the simple leak reporting at the end of the CRT)

If I don’t find a decent utility, I still have to rely on my own memory manager (which does it perfectly).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T04:15:43+00:00Added an answer on May 15, 2026 at 4:15 am

    CRT memory leaks detection (without stack trace):

    // debug_new.h
    #pragma once
    
    #include "crtdbg.h"
    
    #ifdef _DEBUG
    #ifndef DEBUG_NEW
    #define DEBUG_NEW   new( _NORMAL_BLOCK, __FILE__, __LINE__)
    #endif
    #endif
    

    All .cpp files:

    #include "debug_new.h"
    
    ...
    
    // After all other include lines:
    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    
    ...
    

    Write this once in the program initialization code:

    _CrtSetDbgFlag( _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG) | _CRTDBG_LEAK_CHECK_DF);
    

    In MFC, all this is already implemented in MFC headers. You only need to ensure, that every cpp file contains these lines:

    #ifdef _DEBUG
    #define new DEBUG_NEW
    #endif
    

    Restrictions: this catches only “new” memory leaks, all leaks, caused by another functions, like malloc, are not caught.

    Don’t make any allocations inside of .h files – they will be printed without source lines, because DEBUG_NEW is defined after all #include lines.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to find memory leaks in my java application but I don't know
I want to find out what libraries are using the most memory. I want
I want an aleternative to find total memory usage and memory used by individual
I want to use the MallocDebug app to find some memory leaks in my
I'm trying to find a memory leak in my application and I want to
i want to find factorial a number which i take memory first.(intel 8085) edit:
I have an application that keeps using up more and more memory as time
I habe a few million objects hanging around in memory. I want to find
I know how to get the System memory use using GlobalMemoryStatusEx, but that tells
Is there any way to find memory leaks in javascript or jquery. i am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.