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 Leak please help

Memory Leak please help

Scheduled Pinned Locked Moved C / C++ / MFC
c++performancehelp
8 Posts 3 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.
  • U Offline
    U Offline
    uday kiran janaswamy
    wrote on last edited by
    #1

    Hi all, I am having a memory leak. // senario //To include CGTDObjectShape class #include "GTDObjectShape.h" in .h Class class CGTDSwitchBasic : public CObject { public : CGTDObjectShape *mC_ONShape; // CGTDObjectShape class CGTDObjectShape *mC_OFFShape; // CGTDObjectShape class }; in .CPP Class CGTDSwitchBasic::CGTDSwitchBasic(UINT pui_SwitchDrawObjID) { // Create a new Instace of the Object Shape. mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1); } --> Memory Leak after Closing the Application GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long. //=========================================================================== Please help me out.

    Uday kiran

    P N 3 Replies Last reply
    0
    • U uday kiran janaswamy

      Hi all, I am having a memory leak. // senario //To include CGTDObjectShape class #include "GTDObjectShape.h" in .h Class class CGTDSwitchBasic : public CObject { public : CGTDObjectShape *mC_ONShape; // CGTDObjectShape class CGTDObjectShape *mC_OFFShape; // CGTDObjectShape class }; in .CPP Class CGTDSwitchBasic::CGTDSwitchBasic(UINT pui_SwitchDrawObjID) { // Create a new Instace of the Object Shape. mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1); } --> Memory Leak after Closing the Application GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long. //=========================================================================== Please help me out.

      Uday kiran

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      uday kiran janaswamy wrote:

      // Create a new Instace of the Object Shape. mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1);

      Where you have deleted this memory ?

      Prasad Notifier using ATL | Operator new[],delete[][^]

      U 1 Reply Last reply
      0
      • U uday kiran janaswamy

        Hi all, I am having a memory leak. // senario //To include CGTDObjectShape class #include "GTDObjectShape.h" in .h Class class CGTDSwitchBasic : public CObject { public : CGTDObjectShape *mC_ONShape; // CGTDObjectShape class CGTDObjectShape *mC_OFFShape; // CGTDObjectShape class }; in .CPP Class CGTDSwitchBasic::CGTDSwitchBasic(UINT pui_SwitchDrawObjID) { // Create a new Instace of the Object Shape. mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1); } --> Memory Leak after Closing the Application GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long. //=========================================================================== Please help me out.

        Uday kiran

        N Offline
        N Offline
        Nibu babu thomas
        wrote on last edited by
        #3

        uday kiran janaswamy wrote:

        client block at 0x0D732450

        There is an article in MSDN with the following heading "Detecting and Isolating Memory Leaks Using Microsoft Visual C++" This artcile will explain to you what are client blocks and normal blocks and how to set breakpoints on allocations.


        Nibu thomas A Developer Programming tips[^]  My site[^]

        1 Reply Last reply
        0
        • P prasad_som

          uday kiran janaswamy wrote:

          // Create a new Instace of the Object Shape. mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1);

          Where you have deleted this memory ?

          Prasad Notifier using ATL | Operator new[],delete[][^]

          U Offline
          U Offline
          uday kiran janaswamy
          wrote on last edited by
          #4

          hi prasad, //Code Snippet. //================================================================== CGTDSwitchBasic::~CGTDSwitchBasic() { if(mC_ONShape){ delete mC_ONShape; //Deleted Here } if(mC_OFFShape){ delete mC_OFFShape; //Delete Here } } //================================================================== please give your suggestions.

          Uday kiran

          P 1 Reply Last reply
          0
          • U uday kiran janaswamy

            hi prasad, //Code Snippet. //================================================================== CGTDSwitchBasic::~CGTDSwitchBasic() { if(mC_ONShape){ delete mC_ONShape; //Deleted Here } if(mC_OFFShape){ delete mC_OFFShape; //Delete Here } } //================================================================== please give your suggestions.

            Uday kiran

            P Offline
            P Offline
            prasad_som
            wrote on last edited by
            #5

            How you are using CGTDSwitchBasic object? If its pointer, probably its not deleted , which inturn causing this leak. Probably , providing more code should do.

            uday kiran janaswamy wrote:

            if(mC_ONShape){ delete mC_ONShape; //Deleted Here }

            There is no harm calling delete on NULL pointer. You can avoid if statement here. Just set pointer to NULL after deleting it.

            Prasad Notifier using ATL | Operator new[],delete[][^]

            1 Reply Last reply
            0
            • U uday kiran janaswamy

              Hi all, I am having a memory leak. // senario //To include CGTDObjectShape class #include "GTDObjectShape.h" in .h Class class CGTDSwitchBasic : public CObject { public : CGTDObjectShape *mC_ONShape; // CGTDObjectShape class CGTDObjectShape *mC_OFFShape; // CGTDObjectShape class }; in .CPP Class CGTDSwitchBasic::CGTDSwitchBasic(UINT pui_SwitchDrawObjID) { // Create a new Instace of the Object Shape. mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); mC_OFFShape = new CGTDObjectShape(pui_SwitchDrawObjID , 1); } --> Memory Leak after Closing the Application GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long. //=========================================================================== Please help me out.

              Uday kiran

              P Offline
              P Offline
              prasad_som
              wrote on last edited by
              #6

              uday kiran janaswamy wrote:

              GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long.

              What is line 70 in your cpp ?

              Prasad Notifier using ATL | Operator new[],delete[][^]

              U 1 Reply Last reply
              0
              • P prasad_som

                uday kiran janaswamy wrote:

                GTDSwitchBasic.cpp(70) : {185679} client block at 0x0D732450, subtype c0, 200 bytes long.

                What is line 70 in your cpp ?

                Prasad Notifier using ATL | Operator new[],delete[][^]

                U Offline
                U Offline
                uday kiran janaswamy
                wrote on last edited by
                #7

                Hi Prasad, The Line 70 is mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); //Line 70. Please help me out prasad.

                Uday kiran

                P 1 Reply Last reply
                0
                • U uday kiran janaswamy

                  Hi Prasad, The Line 70 is mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); //Line 70. Please help me out prasad.

                  Uday kiran

                  P Offline
                  P Offline
                  prasad_som
                  wrote on last edited by
                  #8

                  Does d'tor of CGTDSwitchBasic is getting called ? If CGTDSwitchBasic is created on heap, are you calling delete on it ? Does c'tor of class CGTDObjectShape does some memory allocation , which is not getting deleted ?

                  Prasad Notifier using ATL | Operator new[],delete[][^]

                  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