mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-28 14:32:38 +03:00
Fixed memory leaks when using syntactic language model.
This commit is contained in:
parent
c810902901
commit
6793fb9635
@ -29,7 +29,7 @@ namespace Moses
|
|||||||
|
|
||||||
SyntacticLanguageModel::~SyntacticLanguageModel() {
|
SyntacticLanguageModel::~SyntacticLanguageModel() {
|
||||||
VERBOSE(3,"Destructing SyntacticLanguageModel" << std::endl);
|
VERBOSE(3,"Destructing SyntacticLanguageModel" << std::endl);
|
||||||
// delete m_files;
|
delete m_files;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t SyntacticLanguageModel::GetNumScoreComponents() const {
|
size_t SyntacticLanguageModel::GetNumScoreComponents() const {
|
||||||
@ -86,10 +86,7 @@ namespace Moses
|
|||||||
|
|
||||||
VERBOSE(3,"Evaluating SyntacticLanguageModel for a hypothesis" << endl);
|
VERBOSE(3,"Evaluating SyntacticLanguageModel for a hypothesis" << endl);
|
||||||
|
|
||||||
const SyntacticLanguageModelState<YModel,XModel,S,R>& prev =
|
SyntacticLanguageModelState<YModel,XModel,S,R>* tmpState = NULL;
|
||||||
static_cast<const SyntacticLanguageModelState<YModel,XModel,S,R>&>(*prev_state);
|
|
||||||
|
|
||||||
const SyntacticLanguageModelState<YModel,XModel,S,R>* currentState = &prev;
|
|
||||||
SyntacticLanguageModelState<YModel,XModel,S,R>* nextState = NULL;
|
SyntacticLanguageModelState<YModel,XModel,S,R>* nextState = NULL;
|
||||||
|
|
||||||
|
|
||||||
@ -103,10 +100,11 @@ namespace Moses
|
|||||||
const std::string& string = factor->GetString();
|
const std::string& string = factor->GetString();
|
||||||
|
|
||||||
if (i==0) {
|
if (i==0) {
|
||||||
nextState = new SyntacticLanguageModelState<YModel,XModel,S,R>(&prev, string);
|
nextState = new SyntacticLanguageModelState<YModel,XModel,S,R>((const SyntacticLanguageModelState<YModel,XModel,S,R>*)prev_state, string);
|
||||||
} else {
|
} else {
|
||||||
currentState = nextState;
|
tmpState = nextState;
|
||||||
nextState = new SyntacticLanguageModelState<YModel,XModel,S,R>(currentState, string);
|
nextState = new SyntacticLanguageModelState<YModel,XModel,S,R>(tmpState, string);
|
||||||
|
delete tmpState;
|
||||||
}
|
}
|
||||||
|
|
||||||
double score = nextState->getScore();
|
double score = nextState->getScore();
|
||||||
|
@ -69,8 +69,8 @@ template <class MH, class MO>
|
|||||||
SyntacticLanguageModelFiles<MH,MO>::~SyntacticLanguageModelFiles() {
|
SyntacticLanguageModelFiles<MH,MO>::~SyntacticLanguageModelFiles() {
|
||||||
|
|
||||||
VERBOSE(3,"Destructing syntactic language model files" << std::endl);
|
VERBOSE(3,"Destructing syntactic language model files" << std::endl);
|
||||||
//delete hiddenModel;
|
delete hiddenModel;
|
||||||
//delete observedModel;
|
delete observedModel;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ template <class MY, class MX, class YS=typename MY::RandVarType, class B=NullBac
|
|||||||
|
|
||||||
~SyntacticLanguageModelState() {
|
~SyntacticLanguageModelState() {
|
||||||
VERBOSE(3,"Destructing SyntacticLanguageModelState" << std::endl);
|
VERBOSE(3,"Destructing SyntacticLanguageModelState" << std::endl);
|
||||||
//delete randomVariableStore;
|
delete randomVariableStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
virtual int Compare(const FFState& other) const;
|
virtual int Compare(const FFState& other) const;
|
||||||
|
Loading…
Reference in New Issue
Block a user