fix bug, see details in ChangeLog.md

This commit is contained in:
yanyiwu 2016-01-29 00:30:38 +08:00
parent 8ca338d75a
commit 721b34f1bd
3 changed files with 9 additions and 5 deletions

View File

@ -1,5 +1,10 @@
# CppJieba ChangeLog # CppJieba ChangeLog
## next version
+ 使用 valgrind 检查内存泄露的问题定位出一个HMM模型初始化的问题导致内存泄露的bug不过此内存泄露不是致命问题
因为只会在词典载入的时候发生,而词典载入通常情况下只会被运行一次,故不会导致致命问题。
## v4.4.0 ## v4.4.0
+ 加代码容易删代码难,思索良久,还是决定把 Server 功能的源码剥离出这个项目。 + 加代码容易删代码难,思索良久,还是决定把 Server 功能的源码剥离出这个项目。

View File

@ -11,8 +11,8 @@
namespace cppjieba { namespace cppjieba {
class HMMSegment: public SegmentBase { class HMMSegment: public SegmentBase {
public: public:
HMMSegment(const string& filePath) { HMMSegment(const string& filePath)
model_ = new HMMModel(filePath); : model_(new HMMModel(filePath)), isNeedDestroy_(true) {
} }
HMMSegment(const HMMModel* model) HMMSegment(const HMMModel* model)
: model_(model), isNeedDestroy_(false) { : model_(model), isNeedDestroy_(false) {

View File

@ -12,9 +12,8 @@ namespace cppjieba {
class MPSegment: public SegmentBase { class MPSegment: public SegmentBase {
public: public:
MPSegment(const string& dictPath, const string& userDictPath = "") { MPSegment(const string& dictPath, const string& userDictPath = "")
dictTrie_ = new DictTrie(dictPath, userDictPath); : dictTrie_(new DictTrie(dictPath, userDictPath)), isNeedDestroy_(true) {
isNeedDestroy_ = true;
} }
MPSegment(const DictTrie* dictTrie) MPSegment(const DictTrie* dictTrie)
: dictTrie_(dictTrie), isNeedDestroy_(false) { : dictTrie_(dictTrie), isNeedDestroy_(false) {