mirror of
https://github.com/moses-smt/mosesdecoder.git
synced 2024-08-16 23:10:31 +03:00
- Fixed a minor memory leak in LanguageKenLM
- Used boost as a workaround for a bigger leak in PhraseDictionaryTree (dynamic allocation in a static function) git-svn-id: https://mosesdecoder.svn.sourceforge.net/svnroot/mosesdecoder/branches/augmLMResult@4137 1f5c12ca-751b-0410-a591-d2e778427230
This commit is contained in:
parent
fca5efdb0b
commit
5c773376d3
@ -127,12 +127,14 @@ template <class Model> void LanguageModelKen<Model>::TranslateIDs(const std::vec
|
||||
}
|
||||
|
||||
template <class Model> LanguageModelKen<Model>::LanguageModelKen(bool lazy)
|
||||
:m_ngram(NULL), m_lazy(lazy)
|
||||
:m_ngram(NULL), m_lazy(lazy), m_nullContextState(NULL), m_beginSentenceState(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
template <class Model> LanguageModelKen<Model>::~LanguageModelKen()
|
||||
{
|
||||
delete m_nullContextState;
|
||||
delete m_beginSentenceState;
|
||||
delete m_ngram;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,6 @@
|
||||
// $Id$
|
||||
// vim:tabstop=2
|
||||
#include <boost/shared_ptr.hpp>
|
||||
#include "PhraseDictionaryTree.h"
|
||||
#include <map>
|
||||
#include <cassert>
|
||||
@ -121,18 +122,19 @@ typedef LVoc<std::string> WordVoc;
|
||||
|
||||
static WordVoc* ReadVoc(const std::string& filename)
|
||||
{
|
||||
static std::map<std::string,WordVoc*> vocs;
|
||||
static std::map<std::string,boost::shared_ptr<WordVoc> > vocs;
|
||||
#ifdef WITH_THREADS
|
||||
boost::mutex mutex;
|
||||
boost::mutex::scoped_lock lock(mutex);
|
||||
#endif
|
||||
std::map<std::string,WordVoc*>::iterator vi = vocs.find(filename);
|
||||
std::map<std::string,boost::shared_ptr<WordVoc> >::iterator vi = vocs.find(filename);
|
||||
if (vi == vocs.end()) {
|
||||
WordVoc* voc = new WordVoc();
|
||||
voc->Read(filename);
|
||||
vocs[filename] = voc;
|
||||
boost::shared_ptr<WordVoc> p(new WordVoc());
|
||||
// WordVoc* voc = new WordVoc();
|
||||
p.get()->Read(filename);
|
||||
vocs[filename] = p;
|
||||
}
|
||||
return vocs[filename];
|
||||
return vocs[filename].get();
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user