mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-30 23:42:30 +03:00
use mempool to stem leak
This commit is contained in:
parent
849b161bf8
commit
15b8c97fce
@ -9,6 +9,11 @@
|
||||
|
||||
namespace Moses2
|
||||
{
|
||||
InputType::InputType(long translationId, MemPool &pool)
|
||||
:m_translationId(translationId)
|
||||
,m_reorderingConstraint(pool)
|
||||
{
|
||||
}
|
||||
|
||||
InputType::~InputType()
|
||||
{
|
||||
|
@ -15,11 +15,7 @@ namespace Moses2
|
||||
class InputType
|
||||
{
|
||||
public:
|
||||
InputType(long translationId) :
|
||||
m_translationId(translationId)
|
||||
{
|
||||
}
|
||||
|
||||
InputType(long translationId, MemPool &pool);
|
||||
virtual ~InputType();
|
||||
|
||||
virtual void Init(size_t size, int max_distortion);
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
const System &system, const std::string &str, long translationId);
|
||||
|
||||
Sentence(long translationId, MemPool &pool, size_t size)
|
||||
:InputType(translationId)
|
||||
:InputType(translationId, pool)
|
||||
,PhraseImpl(pool, size)
|
||||
{}
|
||||
|
||||
|
@ -12,16 +12,17 @@ namespace Moses2
|
||||
//! destructer
|
||||
ReorderingConstraint::~ReorderingConstraint()
|
||||
{
|
||||
if (m_wall != NULL) free(m_wall);
|
||||
if (m_localWall != NULL) free(m_localWall);
|
||||
//if (m_wall != NULL) free(m_wall);
|
||||
//if (m_localWall != NULL) free(m_localWall);
|
||||
}
|
||||
|
||||
//! allocate memory for reordering walls
|
||||
void ReorderingConstraint::InitializeWalls(size_t size, int max_distortion)
|
||||
{
|
||||
m_size = size;
|
||||
m_wall = (bool*) malloc(sizeof(bool) * size);
|
||||
m_localWall = (size_t*) malloc(sizeof(size_t) * size);
|
||||
|
||||
m_wall = m_pool.Allocate<bool>(size);
|
||||
m_localWall = m_pool.Allocate<size_t>(size);
|
||||
|
||||
m_max_distortion = max_distortion;
|
||||
|
||||
|
@ -6,6 +6,7 @@ namespace Moses2
|
||||
{
|
||||
class Sentence;
|
||||
class Bitmap;
|
||||
class MemPool;
|
||||
|
||||
#define NOT_A_ZONE 999999999
|
||||
|
||||
@ -20,16 +21,18 @@ protected:
|
||||
std::vector< std::vector< size_t > > m_zone; /** zones that limit reordering */
|
||||
bool m_active; /**< flag indicating, if there are any active constraints */
|
||||
int m_max_distortion;
|
||||
MemPool &m_pool;
|
||||
|
||||
ReorderingConstraint(const ReorderingConstraint &); // do not implement
|
||||
|
||||
public:
|
||||
|
||||
//! create ReorderingConstraint of length size and initialise to zero
|
||||
ReorderingConstraint()
|
||||
ReorderingConstraint(MemPool &pool)
|
||||
: m_wall(NULL)
|
||||
, m_localWall(NULL)
|
||||
, m_active(false)
|
||||
, m_pool(pool)
|
||||
{}
|
||||
|
||||
//! destructer
|
||||
|
@ -27,7 +27,7 @@ public:
|
||||
const System &system, const std::string &str, long translationId);
|
||||
|
||||
Sentence(long translationId, MemPool &pool, size_t size)
|
||||
:InputType(translationId)
|
||||
:InputType(translationId, pool)
|
||||
,PhraseImpl(pool, size)
|
||||
{}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user