mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-09-11 19:27:11 +03:00
mem leak in active chart
This commit is contained in:
parent
8466d6aaf5
commit
9c1d258b62
@ -23,6 +23,7 @@ public:
|
||||
const SCFG::Word *word;
|
||||
const Moses2::HypothesisColl *hypos;
|
||||
|
||||
SymbolBindElement() {}
|
||||
SymbolBindElement(const Range *range, const SCFG::Word *word, const Moses2::HypothesisColl *hypos);
|
||||
|
||||
bool operator==(const SymbolBindElement &compare) const
|
||||
@ -41,11 +42,17 @@ class SymbolBind
|
||||
friend std::ostream& operator<<(std::ostream &, const SymbolBind &);
|
||||
|
||||
public:
|
||||
std::vector<SymbolBindElement> coll;
|
||||
Vector<SymbolBindElement> coll;
|
||||
size_t numNT;
|
||||
|
||||
SymbolBind()
|
||||
:numNT(0)
|
||||
SymbolBind(MemPool &pool)
|
||||
:coll(pool)
|
||||
,numNT(0)
|
||||
{}
|
||||
|
||||
SymbolBind(MemPool &pool, const SymbolBind ©)
|
||||
:coll(copy.coll)
|
||||
,numNT(copy.numNT)
|
||||
{}
|
||||
|
||||
std::vector<const SymbolBindElement*> GetNTElements() const;
|
||||
@ -65,14 +72,16 @@ inline size_t hash_value(const SymbolBind &obj)
|
||||
class ActiveChartEntry
|
||||
{
|
||||
public:
|
||||
SymbolBind symbolBinds;
|
||||
SymbolBind *symbolBinds;
|
||||
|
||||
ActiveChartEntry()
|
||||
ActiveChartEntry(MemPool &pool)
|
||||
:symbolBinds(new (pool.Allocate<SymbolBind>()) SymbolBind(pool))
|
||||
{}
|
||||
|
||||
ActiveChartEntry(const ActiveChartEntry &prevEntry)
|
||||
:symbolBinds(prevEntry.symbolBinds)
|
||||
{}
|
||||
ActiveChartEntry(MemPool &pool, const ActiveChartEntry &prevEntry)
|
||||
{
|
||||
symbolBinds = new (pool.Allocate<SymbolBind>()) SymbolBind(pool, *prevEntry.symbolBinds);
|
||||
}
|
||||
|
||||
protected:
|
||||
};
|
||||
|
@ -152,7 +152,7 @@ TargetPhrases* PhraseTableMemory::Lookup(const Manager &mgr, MemPool &pool,
|
||||
void PhraseTableMemory::InitActiveChart(MemPool &pool, SCFG::InputPath &path) const
|
||||
{
|
||||
size_t ptInd = GetPtInd();
|
||||
ActiveChartEntryMem *chartEntry = new (pool.Allocate<ActiveChartEntryMem>()) ActiveChartEntryMem(*m_rootSCFG);
|
||||
ActiveChartEntryMem *chartEntry = new (pool.Allocate<ActiveChartEntryMem>()) ActiveChartEntryMem(pool, *m_rootSCFG);
|
||||
path.AddActiveChartEntry(ptInd, chartEntry);
|
||||
}
|
||||
|
||||
@ -305,9 +305,9 @@ void PhraseTableMemory::LookupGivenNode(
|
||||
|
||||
if (nextNode) {
|
||||
// new entries
|
||||
ActiveChartEntryMem *chartEntry = new (pool.Allocate<ActiveChartEntryMem>()) ActiveChartEntryMem(*nextNode, prevEntry);
|
||||
ActiveChartEntryMem *chartEntry = new (pool.Allocate<ActiveChartEntryMem>()) ActiveChartEntryMem(pool, *nextNode, prevEntry);
|
||||
|
||||
SCFG::SymbolBind &symbolBind = chartEntry->symbolBinds;
|
||||
SCFG::SymbolBind &symbolBind = *chartEntry->symbolBinds;
|
||||
symbolBind.Add(subPhrasePath.range, wordSought, hypos);
|
||||
|
||||
path.AddActiveChartEntry(ptInd, chartEntry);
|
||||
|
@ -28,17 +28,20 @@ class PhraseTableMemory: public PhraseTable
|
||||
//////////////////////////////////////
|
||||
class ActiveChartEntryMem : public SCFG::ActiveChartEntry
|
||||
{
|
||||
typedef SCFG::ActiveChartEntry Parent;
|
||||
public:
|
||||
const PhraseTableMemory::SCFGNODE &node;
|
||||
|
||||
ActiveChartEntryMem(const PhraseTableMemory::SCFGNODE &vnode)
|
||||
:node(vnode)
|
||||
ActiveChartEntryMem(MemPool &pool, const PhraseTableMemory::SCFGNODE &vnode)
|
||||
:Parent(pool)
|
||||
,node(vnode)
|
||||
{}
|
||||
|
||||
ActiveChartEntryMem(
|
||||
MemPool &pool,
|
||||
const PhraseTableMemory::SCFGNODE &vnode,
|
||||
const ActiveChartEntry &prevEntry)
|
||||
:ActiveChartEntry(prevEntry)
|
||||
:Parent(prevEntry)
|
||||
,node(vnode)
|
||||
{}
|
||||
};
|
||||
|
@ -132,7 +132,7 @@ void UnknownWordPenalty::Lookup(MemPool &pool,
|
||||
size_t endPos = path.range.GetEndPos();
|
||||
const SCFG::InputPath &subPhrasePath = *mgr.GetInputPaths().GetMatrix().GetValue(endPos, 1);
|
||||
|
||||
SCFG::SymbolBind symbolBind;
|
||||
SCFG::SymbolBind symbolBind(pool);
|
||||
symbolBind.Add(subPhrasePath.range, lastWord, NULL);
|
||||
|
||||
path.AddTargetPhrase(*this, symbolBind, tp);
|
||||
|
@ -24,6 +24,11 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
Vector(const Vector ©) :
|
||||
Parent(copy)
|
||||
{
|
||||
}
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user