title: Detecting memory leaks in MFC application
body: <p>I'm writing an MFC app using Visual 2017 and when the application exits in debug mode, I get this:</p>
  
  <blockquote>
    <p>Detected memory leaks! Dumping objects -> {74} normal block at
    0x00000230E49A7000, 16 bytes long.  Data: &lt;0   0           > 30 00 97
    E4 30 02 00 00 00 00 00 00 00 00 00 00  Object dump complete.</p>
  </blockquote>
  
  <p>So, in order to know which function is causing the leak, I've added these lines in stdafx.h:</p>
  
  <pre><code>#define _CRTDBG_MAP_ALLOC
  #include &lt;stdlib.h&gt;
  #include &lt;crtdbg.h&gt;
  </code></pre>
  
  <p>And these lines in CWinApp::InitInstance():</p>
  
  <pre><code>_CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF);
  _CrtSetBreakAlloc(74);
  </code></pre>
  
  <p>Though, it did not work. I suspect that the 74th memory allocation number has been made before my code is executed. Which method could I overload to be certain to be called first?</p>