{"action":"created","issue":{"url":"https://api.github.com/repos/yanyiwu/cppjieba/issues/53","labels_url":"https://api.github.com/repos/yanyiwu/cppjieba/issues/53/labels{/name}","comments_url":"https://api.github.com/repos/yanyiwu/cppjieba/issues/53/comments","events_url":"https://api.github.com/repos/yanyiwu/cppjieba/issues/53/events","html_url":"https://github.com/yanyiwu/cppjieba/pull/53","id":129442847,"number":53,"title":"可能存在内存泄漏？","user":{"login":"qinwf","id":7472151,"avatar_url":"https://avatars.githubusercontent.com/u/7472151?v=3","gravatar_id":"","url":"https://api.github.com/users/qinwf","html_url":"https://github.com/qinwf","followers_url":"https://api.github.com/users/qinwf/followers","following_url":"https://api.github.com/users/qinwf/following{/other_user}","gists_url":"https://api.github.com/users/qinwf/gists{/gist_id}","starred_url":"https://api.github.com/users/qinwf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qinwf/subscriptions","organizations_url":"https://api.github.com/users/qinwf/orgs","repos_url":"https://api.github.com/users/qinwf/repos","events_url":"https://api.github.com/users/qinwf/events{/privacy}","received_events_url":"https://api.github.com/users/qinwf/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2016-01-28T12:50:51Z","updated_at":"2016-01-28T17:03:28Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/yanyiwu/cppjieba/pulls/53","html_url":"https://github.com/yanyiwu/cppjieba/pull/53","diff_url":"https://github.com/yanyiwu/cppjieba/pull/53.diff","patch_url":"https://github.com/yanyiwu/cppjieba/pull/53.patch"},"body":"最近R包仓库上的管理者通知代码要在 GCC 5 和 Clang 3.8 上编译的上跑测试。最近这两个编译器都带了 UBSAN 和 内存泄漏等测试。我跑 R 接口的时候发现有内存泄漏。\r\n\r\n这里改了一下 cppjieba 的 travis 和 CMakeLists.txt 的文件，在 travis 上跑，发现也有内存泄漏。\r\n\r\ntravis 运行结果 \r\n\r\nClang-3.6 with UBSAN https://travis-ci.org/qinwf/cppjieba/jobs/105404339, \r\n\r\nGCC-5 with UBSAN https://travis-ci.org/qinwf/cppjieba/jobs/105404340.\r\n\r\n具体泄漏的内容，通过 travis 上的 make test 可能看不到。直接运行 ./test/test.run ./load_test 在程序 exit 的时候就可以看到了。\r\n\r\n```\r\nTest project /cppjieba/build\r\n    Start 1: ./test/test.run\r\n1/3 Test #1: ./test/test.run ..................***Failed   29.35 sec\r\n    Start 2: ./load_test\r\n2/3 Test #2: ./load_test ......................***Failed   46.60 sec\r\n    Start 3: ./demo\r\n3/3 Test #3: ./demo ...........................   Passed    3.57 sec\r\n```"},"comment":{"url":"https://api.github.com/repos/yanyiwu/cppjieba/issues/comments/176284247","html_url":"https://github.com/yanyiwu/cppjieba/pull/53#issuecomment-176284247","issue_url":"https://api.github.com/repos/yanyiwu/cppjieba/issues/53","id":176284247,"user":{"login":"yanyiwu","id":2162645,"avatar_url":"https://avatars.githubusercontent.com/u/2162645?v=3","gravatar_id":"","url":"https://api.github.com/users/yanyiwu","html_url":"https://github.com/yanyiwu","followers_url":"https://api.github.com/users/yanyiwu/followers","following_url":"https://api.github.com/users/yanyiwu/following{/other_user}","gists_url":"https://api.github.com/users/yanyiwu/gists{/gist_id}","starred_url":"https://api.github.com/users/yanyiwu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanyiwu/subscriptions","organizations_url":"https://api.github.com/users/yanyiwu/orgs","repos_url":"https://api.github.com/users/yanyiwu/repos","events_url":"https://api.github.com/users/yanyiwu/events{/privacy}","received_events_url":"https://api.github.com/users/yanyiwu/received_events","type":"User","site_admin":false},"created_at":"2016-01-28T17:03:28Z","updated_at":"2016-01-28T17:03:28Z","body":"@qinwf 我刚才也刚好正在用 valgrind 测试，也发现了这个问题，没想到碰巧你也正在测试，非常感谢你，这么晚了还在帮忙定位bug。\r\n我已经在master代码里面修复了这个bug，确实如猜想的那样，就是在载入的时候发生一次性的内存泄露的问题：\r\n\r\n> 使用 valgrind 检查内存泄露的问题，定位出一个HMM模型初始化的问题导致内存泄露的bug，不过此内存泄露不是致命问题，\r\n> 因为只会在词典载入的时候发生，而词典载入通常情况下只会被运行一次，故不会导致严重问题。\r\n\r\n所以希望使用老版本的cppjieba的用户也不必担心。\r\n\r\n目前最新代码使用 valgrind 内存检查是没有问题了，但是不知道你说的那个gcc5的检测是否仍然有问题，我预计应该是没有问题了。不过我这边没有对应的环境，希望你能更新一下最新代码试试，期待你的反馈，非常感谢！如果你有空来北京的话，希望能请你吃顿饭以表谢意。"}}