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