mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-22 14:05:36 +05:00
21948: EDF SMESH : Memory is not freed when deleting a mesh
+ void clear()
This commit is contained in:
parent
2eb294fdc3
commit
fa38ad0b49
@ -21,9 +21,18 @@
|
|||||||
#define _OBJECTPOOL_HXX_
|
#define _OBJECTPOOL_HXX_
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include <stack>
|
//#include <stack>
|
||||||
#include <iostream>
|
#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
|
template<class X> class ObjectPool
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -70,7 +79,7 @@ public:
|
|||||||
|
|
||||||
virtual ~ObjectPool()
|
virtual ~ObjectPool()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _chunkList.size(); i++)
|
for (size_t i = 0; i < _chunkList.size(); i++)
|
||||||
delete[] _chunkList[i];
|
delete[] _chunkList[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +110,7 @@ public:
|
|||||||
void destroy(X* obj)
|
void destroy(X* obj)
|
||||||
{
|
{
|
||||||
long adrobj = (long) (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];
|
X* chunk = _chunkList[i];
|
||||||
long adrmin = (long) (chunk);
|
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)
|
// void destroy(int toFree)
|
||||||
// {
|
// {
|
||||||
// // no control 0<= toFree < _freeList.size()
|
// // no control 0<= toFree < _freeList.size()
|
||||||
|
Loading…
Reference in New Issue
Block a user