diff options
author | Lane Schwartz <dowobeha@gmail.com> | 2012-03-31 00:28:22 +0400 |
---|---|---|
committer | Lane Schwartz <dowobeha@gmail.com> | 2012-03-31 00:28:22 +0400 |
commit | 6793fb9635d7f6d1c8613e0e0bffc1aa609c80e4 (patch) | |
tree | 806bfe8aefba233959fc89a8aa34bdfc092d6934 /moses | |
parent | c8109029017f8a0b02ba08e452e6d932a06784ce (diff) |
Fixed memory leaks when using syntactic language model.
Diffstat (limited to 'moses')
-rw-r--r-- | moses/src/SyntacticLanguageModel.cpp | 14 | ||||
-rw-r--r-- | moses/src/SyntacticLanguageModelFiles.h | 4 | ||||
-rw-r--r-- | moses/src/SyntacticLanguageModelState.h | 2 |
3 files changed, 9 insertions, 11 deletions
diff --git a/moses/src/SyntacticLanguageModel.cpp b/moses/src/SyntacticLanguageModel.cpp index 80802a568..12ade1ff7 100644 --- a/moses/src/SyntacticLanguageModel.cpp +++ b/moses/src/SyntacticLanguageModel.cpp @@ -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(); diff --git a/moses/src/SyntacticLanguageModelFiles.h b/moses/src/SyntacticLanguageModelFiles.h index d0da9fc88..2e12e88c6 100644 --- a/moses/src/SyntacticLanguageModelFiles.h +++ b/moses/src/SyntacticLanguageModelFiles.h @@ -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; } diff --git a/moses/src/SyntacticLanguageModelState.h b/moses/src/SyntacticLanguageModelState.h index 1be4e03b8..1c7d0dcd8 100644 --- a/moses/src/SyntacticLanguageModelState.h +++ b/moses/src/SyntacticLanguageModelState.h @@ -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; |