From 7a5a078d1932d45955b4e29dbb8d449fd1b78ca1 Mon Sep 17 00:00:00 2001 From: Hieu Hoang Date: Fri, 4 Dec 2015 21:52:54 +0000 Subject: [PATCH] delete MemPoolAllocator. Leaks --- contrib/other-builds/moses2/Main.cpp | 2 +- contrib/other-builds/moses2/MemPool.h | 52 ------------------- contrib/other-builds/moses2/Recycler.h | 2 +- .../moses2/Search/CubePruning/Misc.h | 2 +- .../moses2/Search/CubePruning/Search.cpp | 5 +- .../moses2/Search/CubePruning/Search.h | 2 +- .../moses2/Search/CubePruning/Stack.h | 4 +- .../moses2/Search/CubePruning/Stacks.h | 2 +- contrib/other-builds/moses2/Search/Stack.h | 2 +- 9 files changed, 12 insertions(+), 61 deletions(-) diff --git a/contrib/other-builds/moses2/Main.cpp b/contrib/other-builds/moses2/Main.cpp index c13de10ee..9da19347a 100644 --- a/contrib/other-builds/moses2/Main.cpp +++ b/contrib/other-builds/moses2/Main.cpp @@ -70,7 +70,7 @@ int main(int argc, char** argv) void Temp() { - vector > v; + vector v; v.push_back(33); } diff --git a/contrib/other-builds/moses2/MemPool.h b/contrib/other-builds/moses2/MemPool.h index cb130c4ee..9574d044d 100644 --- a/contrib/other-builds/moses2/MemPool.h +++ b/contrib/other-builds/moses2/MemPool.h @@ -74,58 +74,6 @@ class MemPool { MemPool &operator=(const MemPool &); }; -//////////////////////////////////////////////////////////////////////////////////////////////// -template -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 other; }; - - MemPoolAllocator() {} - MemPoolAllocator(const MemPoolAllocator &other) {} - - template< class U > - MemPoolAllocator( const MemPoolAllocator& other ) {} - - size_type max_size() const - { return std::numeric_limits::max(); } - - void deallocate( pointer p, size_type n ) - { - //std::cerr << "deallocate " << p << " " << n << std::endl; - } - - pointer allocate( size_type n, std::allocator::const_pointer hint = 0 ) - { - //std::cerr << "allocate " << n << " " << hint << std::endl; - pointer ret = m_pool.Allocate(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 class ObjectPoolContiguous { diff --git a/contrib/other-builds/moses2/Recycler.h b/contrib/other-builds/moses2/Recycler.h index bc8b6893e..bf4a07e4e 100644 --- a/contrib/other-builds/moses2/Recycler.h +++ b/contrib/other-builds/moses2/Recycler.h @@ -12,7 +12,7 @@ template class Recycler { - typedef std::vector > Coll; + typedef std::vector Coll; public: typedef typename Coll::iterator iterator; diff --git a/contrib/other-builds/moses2/Search/CubePruning/Misc.h b/contrib/other-builds/moses2/Search/CubePruning/Misc.h index 974cef69c..8d7bf08d4 100644 --- a/contrib/other-builds/moses2/Search/CubePruning/Misc.h +++ b/contrib/other-builds/moses2/Search/CubePruning/Misc.h @@ -54,7 +54,7 @@ class CubeEdge public: typedef std::vector Hypotheses; typedef std::priority_queue >, + std::vector, QueueItemOrderer> Queue; const Hypotheses &hypos; diff --git a/contrib/other-builds/moses2/Search/CubePruning/Search.cpp b/contrib/other-builds/moses2/Search/CubePruning/Search.cpp index 15554722f..1a12717bf 100644 --- a/contrib/other-builds/moses2/Search/CubePruning/Search.cpp +++ b/contrib/other-builds/moses2/Search/CubePruning/Search.cpp @@ -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 void Search::Decode(size_t stackInd) { - std::vector > &queueContainer = Container(m_queue); + std::vector &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) diff --git a/contrib/other-builds/moses2/Search/CubePruning/Search.h b/contrib/other-builds/moses2/Search/CubePruning/Search.h index 88c3ad619..577f7c1d7 100644 --- a/contrib/other-builds/moses2/Search/CubePruning/Search.h +++ b/contrib/other-builds/moses2/Search/CubePruning/Search.h @@ -34,7 +34,7 @@ protected: // CUBE PRUNING VARIABLES // setup - typedef std::vector > CubeEdges; + typedef std::vector CubeEdges; std::vector m_cubeEdges; // CUBE PRUNING diff --git a/contrib/other-builds/moses2/Search/CubePruning/Stack.h b/contrib/other-builds/moses2/Search/CubePruning/Stack.h index 8c9d88470..ce40eb810 100644 --- a/contrib/other-builds/moses2/Search/CubePruning/Stack.h +++ b/contrib/other-builds/moses2/Search/CubePruning/Stack.h @@ -23,8 +23,8 @@ class HypothesisSet { public: typedef boost::unordered_set, UnorderedComparer, - MemPoolAllocator > _HCType; + UnorderedComparer, UnorderedComparer + > _HCType; _HCType &GetColl() { return m_coll; } diff --git a/contrib/other-builds/moses2/Search/CubePruning/Stacks.h b/contrib/other-builds/moses2/Search/CubePruning/Stacks.h index 9d4096d65..00b20447e 100644 --- a/contrib/other-builds/moses2/Search/CubePruning/Stacks.h +++ b/contrib/other-builds/moses2/Search/CubePruning/Stacks.h @@ -33,7 +33,7 @@ public: void Add(const Hypothesis *hypo, Recycler &hypoRecycle); protected: - std::vector > m_stacks; + std::vector m_stacks; }; diff --git a/contrib/other-builds/moses2/Search/Stack.h b/contrib/other-builds/moses2/Search/Stack.h index 2f9e62e9e..d881913e3 100644 --- a/contrib/other-builds/moses2/Search/Stack.h +++ b/contrib/other-builds/moses2/Search/Stack.h @@ -14,7 +14,7 @@ class Stack { protected: - typedef boost::unordered_set, UnorderedComparer, MemPoolAllocator > _HCType; + typedef boost::unordered_set, UnorderedComparer > _HCType; _HCType m_hypos; public: typedef _HCType::iterator iterator;