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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Destructors not invoked -> Memory leaks

Destructors not invoked -> Memory leaks

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancehelpquestionannouncement
2 Posts 2 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.
  • N Offline
    N Offline
    Nyarlatotep
    wrote on last edited by
    #1

    I've built an SDI application without problems, adding classes. When I've linked a thirdy party library i've had to change compiler switch from Multithreaded (/MT) to Multithreaded DLL (/MD) and adding the _AFXDLL symbol to properly compile the entire project. The project is linked with the shard version of MFC. When the application exits, i've noticed a lot of memory leaks and that classes destructors are not invoked (CView derived class and CMainFrame destructors are invoked, but CDocument destructor and other classes destructors are not invoked). I can't understand the causes of this problem and if the /MD compiler option is one of them. Any idea ?

    W 1 Reply Last reply
    0
    • N Nyarlatotep

      I've built an SDI application without problems, adding classes. When I've linked a thirdy party library i've had to change compiler switch from Multithreaded (/MT) to Multithreaded DLL (/MD) and adding the _AFXDLL symbol to properly compile the entire project. The project is linked with the shard version of MFC. When the application exits, i've noticed a lot of memory leaks and that classes destructors are not invoked (CView derived class and CMainFrame destructors are invoked, but CDocument destructor and other classes destructors are not invoked). I can't understand the causes of this problem and if the /MD compiler option is one of them. Any idea ?

      W Offline
      W Offline
      Waldermort
      wrote on last edited by
      #2

      Take a look at where and how you create an instance of the class. The probable cause is that you have created an instance somewhere with the keyword new, and you are failing to call delete. If that class has other classes as members, their destructors will in turn fail to be called.

      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