Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
imRainChen opened this issue Dec 13, 2021 · 6 comments
Open

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

imRainChen opened this issue Dec 13, 2021 · 6 comments

Comments

@imRainChen
Copy link

近日发现服务器内存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进程被杀掉

@ZhuRongGo
Copy link

有修复了吗?

@zhaochenxiao90
Copy link

你们怎么解决的

@imRainChen
Copy link
Author

容器镜像换成 alpine 的解决了,不确定具体原因

@leijiru1994
Copy link

容器镜像换成 alpine 的解决了,不确定具体原因

换成alpine镜像,是不是升级了相关lib库

  • 因为需要开启cgo

@hungtcs
Copy link

hungtcs commented Mar 9, 2023

mac m1 上面有类似的问题

@liu86th
Copy link

liu86th commented Jan 10, 2024

运行一段时间自动崩了
image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants