21948: EDF SMESH : Memory is not freed when deleting a mesh

+  void clear()
This commit is contained in:
eap 2012-12-14 13:02:44 +00:00
parent 2eb294fdc3
commit fa38ad0b49

View File

@ -21,9 +21,18 @@
#define _OBJECTPOOL_HXX_
#include <vector>
#include <stack>
//#include <stack>
#include <iostream>
namespace
{
// assure deallocation of memory of a vector
template<class Y> void clearVector(std::vector<Y>& v )
{
std::vector<Y> emptyVec; v.swap( emptyVec );
}
}
template<class X> class ObjectPool
{
@ -70,7 +79,7 @@ public:
virtual ~ObjectPool()
{
for (int i = 0; i < _chunkList.size(); i++)
for (size_t i = 0; i < _chunkList.size(); i++)
delete[] _chunkList[i];
}
@ -101,7 +110,7 @@ public:
void destroy(X* obj)
{
long adrobj = (long) (obj);
for (int i = 0; i < _chunkList.size(); i++)
for (size_t i = 0; i < _chunkList.size(); i++)
{
X* chunk = _chunkList[i];
long adrmin = (long) (chunk);
@ -121,6 +130,16 @@ public:
}
}
void clear()
{
_nextFree = 0;
_maxAvail = 0;
for (size_t i = 0; i < _chunkList.size(); i++)
delete[] _chunkList[i];
clearVector( _chunkList );
clearVector( _freeList );
}
// void destroy(int toFree)
// {
// // no control 0<= toFree < _freeList.size()