mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2025-01-08 20:46:59 +03:00
delete MemPoolAllocator. Leaks
This commit is contained in:
parent
59272a0180
commit
7a5a078d19
@ -70,7 +70,7 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
void Temp()
|
void Temp()
|
||||||
{
|
{
|
||||||
vector<int, MemPoolAllocator<int> > v;
|
vector<int> v;
|
||||||
v.push_back(33);
|
v.push_back(33);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -74,58 +74,6 @@ class MemPool {
|
|||||||
MemPool &operator=(const 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>
|
template <typename T>
|
||||||
class ObjectPoolContiguous {
|
class ObjectPoolContiguous {
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class Recycler {
|
class Recycler {
|
||||||
typedef std::vector<T, MemPoolAllocator<T> > Coll;
|
typedef std::vector<T> Coll;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef typename Coll::iterator iterator;
|
typedef typename Coll::iterator iterator;
|
||||||
|
@ -54,7 +54,7 @@ class CubeEdge
|
|||||||
public:
|
public:
|
||||||
typedef std::vector<const Hypothesis*> Hypotheses;
|
typedef std::vector<const Hypothesis*> Hypotheses;
|
||||||
typedef std::priority_queue<QueueItem*,
|
typedef std::priority_queue<QueueItem*,
|
||||||
std::vector<QueueItem*, MemPoolAllocator<QueueItem*> >,
|
std::vector<QueueItem*>,
|
||||||
QueueItemOrderer> Queue;
|
QueueItemOrderer> Queue;
|
||||||
|
|
||||||
const Hypotheses &hypos;
|
const Hypotheses &hypos;
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "../../InputPaths.h"
|
#include "../../InputPaths.h"
|
||||||
#include "../../InputPath.h"
|
#include "../../InputPath.h"
|
||||||
#include "../../System.h"
|
#include "../../System.h"
|
||||||
|
#include "../../legacy/Util2.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ template <class T, class S, class C>
|
|||||||
|
|
||||||
void Search::Decode(size_t stackInd)
|
void Search::Decode(size_t stackInd)
|
||||||
{
|
{
|
||||||
std::vector<QueueItem*, MemPoolAllocator<QueueItem*> > &queueContainer = Container(m_queue);
|
std::vector<QueueItem*> &queueContainer = Container(m_queue);
|
||||||
queueContainer.clear();
|
queueContainer.clear();
|
||||||
|
|
||||||
// add top hypo from every edge into queue
|
// add top hypo from every edge into queue
|
||||||
@ -108,6 +109,8 @@ void Search::Decode(size_t stackInd)
|
|||||||
|
|
||||||
++pops;
|
++pops;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveAllInColl(edges);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Search::PostDecode(size_t stackInd)
|
void Search::PostDecode(size_t stackInd)
|
||||||
|
@ -34,7 +34,7 @@ protected:
|
|||||||
|
|
||||||
// CUBE PRUNING VARIABLES
|
// CUBE PRUNING VARIABLES
|
||||||
// setup
|
// setup
|
||||||
typedef std::vector<CubeEdge*, MemPoolAllocator<CubeEdge*> > CubeEdges;
|
typedef std::vector<CubeEdge*> CubeEdges;
|
||||||
std::vector<CubeEdges> m_cubeEdges;
|
std::vector<CubeEdges> m_cubeEdges;
|
||||||
|
|
||||||
// CUBE PRUNING
|
// CUBE PRUNING
|
||||||
|
@ -23,8 +23,8 @@ class HypothesisSet
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
typedef boost::unordered_set<const Hypothesis*,
|
typedef boost::unordered_set<const Hypothesis*,
|
||||||
UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis>,
|
UnorderedComparer<Hypothesis>, UnorderedComparer<Hypothesis>
|
||||||
MemPoolAllocator<const Hypothesis*> > _HCType;
|
> _HCType;
|
||||||
|
|
||||||
_HCType &GetColl()
|
_HCType &GetColl()
|
||||||
{ return m_coll; }
|
{ return m_coll; }
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
void Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle);
|
void Add(const Hypothesis *hypo, Recycler<Hypothesis*> &hypoRecycle);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::vector<Stack, MemPoolAllocator<Stack> > m_stacks;
|
std::vector<Stack> m_stacks;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
|
|
||||||
class Stack {
|
class Stack {
|
||||||
protected:
|
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;
|
_HCType m_hypos;
|
||||||
public:
|
public:
|
||||||
typedef _HCType::iterator iterator;
|
typedef _HCType::iterator iterator;
|
||||||
|
Loading…
Reference in New Issue
Block a user