yanyiwu / gojieba

"结巴"中文分词的Golang版本
MIT License
2.42k stars 302 forks source link

fix[cgo]: Fix - memory allocted by cgo will not automaticlly free by gc. #96

Closed CNLHC closed 2 years ago

CNLHC commented 2 years ago

Currently, when an object containing a jieba instance is dropped, the memory allocated to jieba will not be freed automatically.

This Pull Request uses runtime.SetFinalizer to invoke Free and avoid memory leaking in the above cases.

yanyiwu commented 2 years ago

Thanks