-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
添加snapshot内存快照debug指令 #848
Open
spin6lock
wants to merge
5
commits into
cloudwu:master
Choose a base branch
from
spin6lock:add_snapshot
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
cloudwu
reviewed
Jun 11, 2018
lualib/skynet/debug.lua
Outdated
@@ -88,6 +88,27 @@ local function init(skynet, export) | |||
skynet.ret() | |||
end | |||
|
|||
local old_snapshot | |||
local snapshot = require "snapshot" |
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.
这两个 require 放在下面 function dbgcmd.SNAPSHOT() 内部更好。这样不使用的时候就不会占内存。(少一个 table)
赞,好东西啊。。 |
把snapshot_utils提交给https://github.com/cloudwu/lua-snapshot ,实现代码没必要放在skynet里面。然后skynet以3rd的方式引用这个库。简单加个gm指令启用就好了。 @cloudwu |
cloudwu
force-pushed
the
master
branch
2 times, most recently
from
December 10, 2021 12:56
31e0ac2
to
208be03
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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相互倒来倒去是希望尽可能少的发生内存分配