Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
通过内存快照对比,可以找出可能存在的内存泄漏,详见云风的博客。一般是通过mem和cmem指令找出内存占用异常的服务,然后对服务的可疑接口调用前打一次snapshot,调用后打一次snapshot,比较diff看看残留的内存对象是否正常。
lua-snapshot.c 来源于云风的lua-snapshot,新添加了类型输出。前后两次内存快照对比出来的diff,会尝试用来组成树以方便阅读,深度限制同lua-seri,方便传送到其他服务。
组成树(森林)的大致过程:先将没有任何引用的叶节点放入a,然后将叶节点的上一层节点放入a,对应叶节点移出a。然后循环,直到所有被引用的节点都在数组为止。a_set和b_set相互倒来倒去是希望尽可能少的发生内存分配