Trying to solve my memory leaks
Hallo,
I am kind of new to taking care of the memory I assign. Before now, I have mostly ignored it (clever right?)
Right now im having a huge problem trying to get rid of a memory leak i have, so if anyone could take a look I would be a very happy man.
Code:
// My class
class Visualisation
{
public:
static Visualisation &GetInstance();
...
protected:
Visualisation();
~Visualisation(void);
private:
static Visualisation *_instance;
...
};
#define VIZ Visualisation::GetInstance()
Visualisation & Visualisation::GetInstance()
{
if (_instance == NULL)
_instance = new Visualisation;
return *_instance;
}
Visualisation::~Visualisation(void)
{
delete _instance;
}
I think the problem has to be in that part of the code(I know for sure it is in the Visualisation class) as its the only new I have in my code. I dont call the destructor, as I have been told that the program calls it when it ends (also tried to call it myself just to be sure, no difference)
Regards,
Ole Kristian