Memory Leak please help
-
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
-
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
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[][^]
-
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
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[^]
-
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[][^]
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
-
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
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 avoidif
statement here. Just set pointer to NULL after deleting it.Prasad Notifier using ATL | Operator new[],delete[][^]
-
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
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[][^]
-
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[][^]
Hi Prasad, The Line 70 is mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); //Line 70. Please help me out prasad.
Uday kiran
-
Hi Prasad, The Line 70 is mC_ONShape = new CGTDObjectShape(pui_SwitchDrawObjID , 0); //Line 70. Please help me out prasad.
Uday kiran
Does d'tor of
CGTDSwitchBasic
is getting called ? IfCGTDSwitchBasic
is created on heap, are you calling delete on it ? Does c'tor of classCGTDObjectShape
does some memory allocation , which is not getting deleted ?Prasad Notifier using ATL | Operator new[],delete[][^]