mercredi 18 février 2015

Boost test memory leaks if virtual destructor implemented in source file

I am trying to run simple unit tests on a class, I get memory leaks detected whenever I implement a virtual destructor in the cpp file, rather than in the declaration.


This works and gives out no errors on the test below:



// Header file
class myClass
{
myClass();
virtual ~myClass(){};
};


This doesn't, it gives me memory leak detection:



/////// Header file
class myClass
{
myClass();
virtual ~myClass();
};


/////// CPP file
#include "myClass.h"

myClass::myClass(){}
myClass::~myClass(){}


Here's my test's code:



#include "myClass.h"
#define BOOST_TEST_MODULE myClassTestModule
#include "boost/test/unit_test.hpp"


BOOST_AUTO_TEST_CASE( u_wot_m8 )
{
BOOST_CHECK(true);
}


The memory leak error shows:



Running 1 test case...
*** No errors detected
Detected memory leaks!
Dumping objects ->
{161} normal block at 0x00657BD8, 4 bytes long.
Data: < mp > E8 6D 70 10
Object dump complete.
Press any key to continue . . .


Why can this be?


Related questions:


A destructor function is causing a memory leak...


Aucun commentaire:

Enregistrer un commentaire