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. Memory Leaks - HELP REALY NEEDED

Memory Leaks - HELP REALY NEEDED

Scheduled Pinned Locked Moved C / C++ / MFC
c++graphicsdebuggingperformancehelp
6 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.
  • K Offline
    K Offline
    klm
    wrote on last edited by
    #1

    Hello, i have a class for flicker-free-drawing, there i have a global pointer to CBitmap, and in the constructor i create a CBitamp-Object via new. In the destructor i would like to delete the object, but my destructor is never called. When i exit my programm the debugger print "Detecting Memory Leaks!" and then the adress of the pointer to the CBitmap object. What can i do? When called windows/Visual c++ the destructor? Please help me!

    D K 2 Replies Last reply
    0
    • K klm

      Hello, i have a class for flicker-free-drawing, there i have a global pointer to CBitmap, and in the constructor i create a CBitamp-Object via new. In the destructor i would like to delete the object, but my destructor is never called. When i exit my programm the debugger print "Detecting Memory Leaks!" and then the adress of the pointer to the CBitmap object. What can i do? When called windows/Visual c++ the destructor? Please help me!

      D Offline
      D Offline
      Daniel Lohmann
      wrote on last edited by
      #2

      The order in which global variables are constructed and destructes is undefined. Therfore it might happen, that the CRT cleanup stuff is called before your destructor is executed and therefore a memory leak is reported. You should check this by adding a breakpoint to your destructer and see if it is reached. -- Daniel Lohmann http://www.losoft.de

      K 1 Reply Last reply
      0
      • D Daniel Lohmann

        The order in which global variables are constructed and destructes is undefined. Therfore it might happen, that the CRT cleanup stuff is called before your destructor is executed and therefore a memory leak is reported. You should check this by adding a breakpoint to your destructer and see if it is reached. -- Daniel Lohmann http://www.losoft.de

        K Offline
        K Offline
        klm
        wrote on last edited by
        #3

        Hello Daniel, I have a breakpoint in the destructor, but the destructor is never called. My problem/question: i have this member-variable of my own class (in the header of a dialog, the member-variable is global): CMyOwnClass m_test; When i exit my programm the debugger print me a message "Detecting Memory Leaks!" with the adress of a CBitmap object. That CBitmap object create i via new i the constructor of CMyOwnClass. And i would like to delete the in the destructor. When call windows/visual c++ the destructor of CMyOwnClass? NEVER? Thank you for your reply!

        D 1 Reply Last reply
        0
        • K klm

          Hello, i have a class for flicker-free-drawing, there i have a global pointer to CBitmap, and in the constructor i create a CBitamp-Object via new. In the destructor i would like to delete the object, but my destructor is never called. When i exit my programm the debugger print "Detecting Memory Leaks!" and then the adress of the pointer to the CBitmap object. What can i do? When called windows/Visual c++ the destructor? Please help me!

          K Offline
          K Offline
          klm
          wrote on last edited by
          #4

          Hello, i have found the error, the error was that i created the dialog where the member-variable is located via new and never delete them, and then the destructor of the base class of the member-variable never called.

          1 Reply Last reply
          0
          • K klm

            Hello Daniel, I have a breakpoint in the destructor, but the destructor is never called. My problem/question: i have this member-variable of my own class (in the header of a dialog, the member-variable is global): CMyOwnClass m_test; When i exit my programm the debugger print me a message "Detecting Memory Leaks!" with the adress of a CBitmap object. That CBitmap object create i via new i the constructor of CMyOwnClass. And i would like to delete the in the destructor. When call windows/visual c++ the destructor of CMyOwnClass? NEVER? Thank you for your reply!

            D Offline
            D Offline
            Daniel Lohmann
            wrote on last edited by
            #5

            Sorry, but this is not clear to me :confused: klm wrote: have this member-variable of my own class (in the header of a dialog, the member-variable is global): CMyOwnClass m_test; Ah, what the hell do you mean with a global member variable? It might help if you post some code (shrinked to the necessary stuff). -- Daniel Lohmann http://www.losoft.de

            K 1 Reply Last reply
            0
            • D Daniel Lohmann

              Sorry, but this is not clear to me :confused: klm wrote: have this member-variable of my own class (in the header of a dialog, the member-variable is global): CMyOwnClass m_test; Ah, what the hell do you mean with a global member variable? It might help if you post some code (shrinked to the necessary stuff). -- Daniel Lohmann http://www.losoft.de

              K Offline
              K Offline
              klm
              wrote on last edited by
              #6

              Hello Daniel, with global member variable mean i: a variable in a class, that is accessable in each function of the class. I think the right word is: member variable. Sorry for my bad english and the "global member variable", but i come from C and i am new Visual C++, i don't have heard member varible before i started with Visual C++

              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