Skip to content

Free函数不能有效释放内存会造成内存泄漏 #87

@imRainChen

Description

@imRainChen

近日发现服务器内存RES不断上涨,最终定位到jieba这里存在内存泄漏问题,测试代码如下:

GO VERSION:1.16.7

func main() {
  loop:
  var list []*gojieba.Jieba
  for i := 0; i < count; i++ {
      // todo: paths not define
      t := gojieba.NewJieba(paths...)
      list = append(list, t)
  }

  time.Sleep(5 * time.Second)

  for i := range list {
      list[i].Free()
  }

  goto loop
}

通过上述代码最终会因内存太大造成OOM进程被杀掉

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions