-
Notifications
You must be signed in to change notification settings - Fork 7
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
Fix memory leak caused by impl.go call libzkp #57
Conversation
defer func() { | ||
C.free(unsafe.Pointer(tracesStr)) | ||
}() | ||
defer C.free(unsafe.Pointer(tracesStr)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how does this change make it different?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some subtle differences, I mainly refer to scroll's update
同步一下进展:
logs for leak-checking by valgrind
通过上面可以看到,libzkp.so 确实是导致了一部分的 possibly lost 和 still reachable,但是不是大头,更多的是因为 secp256k1.c 导致的。然后 libzkp.so 的 log 显示,主要是 env_logger 以及 ccc 的 init, 还有是 hashbrown(就是 std 里面HashMap 用到的库。可能因为 valgrind 的模拟执行根本没有执行到 apply_tx/apply_block 的逻辑。
pgrep geth
# xxx
# use interval of 30 seconds and prune any allocations newer than 5000ms
memleak-bpfcc -p xxx -o 5000 30 能检测到 libzkp.so 的一些东西。这里 提到了是因为
不过把 ubuntu:20.04 改成 ubuntu:bionic 仍然有无法在 container 里面正常运行。既然上面有人在 docker 里面成功运行了(他也说了花了他几个小时安装依赖包之类的),因此这个问题是可以解决的。 参考这个修复 go 调用 ZooKeeper C 库导致的内存泄漏的问题: https://github.com/Shopify/gozk/pull/4/files impl.go 里面需要释放的 C 指针都已经使用 defer C.free()/C.free_c_char() 正确释放了。 |
ref: scroll-tech/scroll#998
1. Purpose or design rationale of this PR
...
2. PR title
Your PR title must follow conventional commits (as we are doing squash merge for each PR), so it must start with one of the following types:
3. Deployment tag versioning
Has the version in
params/version.go
been updated?4. Breaking change label
Does this PR have the
breaking-change
label?