Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to debug memory leaks in MFC program

How to debug memory leaks in MFC program

Scheduled Pinned Locked Moved C / C++ / MFC
c++debuggingperformancetutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    aloktambi
    wrote on last edited by
    #1

    sir, i make obe program in MFC .i want to debug any memory leaks in my program .how can i find out memeory leak

    RaviBeeR T C 3 Replies Last reply
    0
    • A aloktambi

      sir, i make obe program in MFC .i want to debug any memory leaks in my program .how can i find out memeory leak

      RaviBeeR Offline
      RaviBeeR Offline
      RaviBee
      wrote on last edited by
      #2

      See this[^] series of articles. /ravi My new year's resolution: 2048 x 1536 Home | Music | Articles | Freeware | Trips ravib(at)ravib(dot)com

      1 Reply Last reply
      0
      • A aloktambi

        sir, i make obe program in MFC .i want to debug any memory leaks in my program .how can i find out memeory leak

        T Offline
        T Offline
        toxcct
        wrote on last edited by
        #3

        aloktambi wrote:

        how can i find out memeory leak

        by seeing the memory use growing and growing while your application is running... this is very hard to track with a tool... the best thing to avoid memory leaks is still to take much care when handling heap memory... when you malloc() or when you new some memory on the heap, be sure to free() or delete it when it is no longer used...


        TOXCCT >>> GEII power
        [toxcct][VisualCalc]

        1 Reply Last reply
        0
        • A aloktambi

          sir, i make obe program in MFC .i want to debug any memory leaks in my program .how can i find out memeory leak

          C Offline
          C Offline
          Cedric Moonen
          wrote on last edited by
          #4

          If you want an easy solution (yeah, I always prefere a solution where I don't need to read a bunch of articles ;P ), you can simply launch the debugger (press F5) and then, when your program exits, you will have a dump of all memory leaks your program produced (and you can double-click on the lines and it will show where the memory has been allocated). But this works only when the memory has been allocated with new and of course it only shows you the memory leaks your program produced (not all potential ones). That is, if there is function that is called when you press a button and if there is a leak within it, if you don't press the button, the leak won't be detected.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups