delete MemPoolAllocator. Leaks

This commit is contained in:
Hieu Hoang 2015-12-04 21:52:54 +00:00
parent 59272a0180
commit 7a5a078d19
9 changed files with 12 additions and 61 deletions

View File

@ -70,7 +70,7 @@ int main(int argc, char** argv)
void Temp()
{
vector<int, MemPoolAllocator<int> > v;
vector<int> v;
v.push_back(33);
}

View File

@ -74,58 +74,6 @@ class MemPool {
MemPool &operator=(const MemPool &);
};
////////////////////////////////////////////////////////////////////////////////////////////////
template <typename T>
class MemPoolAllocator
{
public:
typedef T value_type;
typedef T* pointer;
typedef const T* const_pointer;
typedef T& reference;
typedef const T& const_reference;
typedef std::size_t size_type;
typedef std::ptrdiff_t difference_type;
template< class U >
struct rebind { typedef MemPoolAllocator<U> other; };
MemPoolAllocator() {}
MemPoolAllocator(const MemPoolAllocator &other) {}
template< class U >
MemPoolAllocator( const MemPoolAllocator<U>& other ) {}
size_type max_size() const
{ return std::numeric_limits<size_type>::max(); }
void deallocate( pointer p, size_type n )
{
//std::cerr << "deallocate " << p << " " << n << std::endl;
}
pointer allocate( size_type n, std::allocator<void>::const_pointer hint = 0 )
{
//std::cerr << "allocate " << n << " " << hint << std::endl;
pointer ret = m_pool.Allocate<T>(n);
return ret;
}
void construct( pointer p, const_reference val )
{
//std::cerr << "construct " << p << " " << n << std::endl;
new((void *)p) T(val);
}
void destroy( pointer p )
{
//std::cerr << "destroy " << p << " " << n << std::endl;
}
protected:
MemPool m_pool;
};
////////////////////////////////////////////////////////////////////////////////////////////////
template <typename T>
class ObjectPoolContiguous {

View File

@ -12,7 +12,7 @@
template<typename T>
class Recycler {
typedef std::vector<T, MemPoolAllocator<T> > Coll;
typedef std::vector<T> Coll;
public:
typedef typename Coll::iterator iterator;

View File

@ -54,7 +54,7 @@ class CubeEdge
public:
typedef std::vector<const Hypothesis*> Hypotheses;
typedef std::priority_queue<QueueItem*,
std::vector<QueueItem*, MemPoolAllocator<QueueItem*> >,
std::vector<QueueItem*>,
QueueItemOrderer> Queue;
const Hypotheses &hypos;

View File

@ -11,6 +11,7 @@
#include "../../InputPaths.h"
#include "../../InputPath.h"
#include "../../System.h"
#include "../../legacy/Util2.h"
using namespace std;
@ -71,7 +72,7 @@ template <class T, class S, class C>
void Search::Decode(size_t stackInd)
{
std::vector<QueueItem*, MemPoolAllocator<QueueItem*> > &queueContainer = Container(m_queue);
std::vector<QueueItem*> &queueContainer = Container(m_queue);
queueContainer.clear();
// add top hypo from every edge into queue
@ -108,6 +109,8 @@ void Search::Decode(size_t stackInd)
++pops;
}
RemoveAllInColl(edges);
}
void Search::PostDecode(size_t stackInd)

View File

@ -34,7 +34,7 @@ protected:
// CUBE PRUNING VARIABLES
// setup
typedef std::vector<CubeEdge*, MemPoolAllocator<CubeEdge*> > CubeEdges;
typedef std::vector<CubeEdge*> CubeEdges;
std::vector<CubeEdges> m_cubeEdges;
// CUBE PRUNING

View File

@ -23,8 +23,8 @@ class HypothesisSet
{
public:
typedef boost::unordered_set<const Hypothesis*,
UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis>,
MemPoolAllocator<const Hypothesis*> > _HCType;
UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis>
> _HCType;
_HCType &GetColl()
{ return m_coll; }

View File

@ -33,7 +33,7 @@ public:
void Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle);
protected:
std::vector<Stack, MemPoolAllocator<Stack> > m_stacks;
std::vector<Stack> m_stacks;
};

View File

@ -14,7 +14,7 @@
class Stack {
protected:
typedef boost::unordered_set<const Hypothesis*, UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis>, MemPoolAllocator<const Hypothesis*> > _HCType;
typedef boost::unordered_set<const Hypothesis*, UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis> > _HCType;
_HCType m_hypos;
public:
typedef _HCType::iterator iterator;