mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-12-27 22:14:57 +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() {
|
||||
VERBOSE(3,"Destructing SyntacticLanguageModel" << std::endl);
|
||||
// delete m_files;
|
||||
delete m_files;
|
||||
}
|
||||
|
||||
size_t SyntacticLanguageModel::GetNumScoreComponents() const {
|
||||
@ -86,10 +86,7 @@ namespace Moses
|
||||
|
||||
VERBOSE(3,"Evaluating SyntacticLanguageModel for a hypothesis" << endl);
|
||||
|
||||
const SyntacticLanguageModelState<YModel,XModel,S,R>& prev =
|
||||
static_cast<const SyntacticLanguageModelState<YModel,XModel,S,R>&>(*prev_state);
|
||||
|
||||
const SyntacticLanguageModelState<YModel,XModel,S,R>* currentState = &prev;
|
||||
SyntacticLanguageModelState<YModel,XModel,S,R>* tmpState = NULL;
|
||||
SyntacticLanguageModelState<YModel,XModel,S,R>* nextState = NULL;
|
||||
|
||||
|
||||
@ -103,10 +100,11 @@ namespace Moses
|
||||
const std::string& string = factor->GetString();
|
||||
|
||||
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 {
|
||||
currentState = nextState;
|
||||
nextState = new SyntacticLanguageModelState<YModel,XModel,S,R>(currentState, string);
|
||||
tmpState = nextState;
|
||||
nextState = new SyntacticLanguageModelState<YModel,XModel,S,R>(tmpState, string);
|
||||
delete tmpState;
|
||||
}
|
||||
|
||||
double score = nextState->getScore();
|
||||
|
@ -69,8 +69,8 @@ template <class MH, class MO>
|
||||
SyntacticLanguageModelFiles<MH,MO>::~SyntacticLanguageModelFiles() {
|
||||
|
||||
VERBOSE(3,"Destructing syntactic language model files" << std::endl);
|
||||
//delete hiddenModel;
|
||||
//delete observedModel;
|
||||
delete hiddenModel;
|
||||
delete observedModel;
|
||||
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ template <class MY, class MX, class YS=typename MY::RandVarType, class B=NullBac
|
||||
|
||||
~SyntacticLanguageModelState() {
|
||||
VERBOSE(3,"Destructing SyntacticLanguageModelState" << std::endl);
|
||||
//delete randomVariableStore;
|
||||
delete randomVariableStore;
|
||||
}
|
||||
|
||||
virtual int Compare(const FFState& other) const;
|
||||
|
Loading…
Reference in New Issue
Block a user