Make a snapshot for lua state to detect memory leaks.
See dump.lua for example.
make linux
or
make mingw (in windows)
or
make macosx
Make a snapshot for lua state to detect memory leaks.
License: MIT License
Could you drop a license file into this project that mentions how this project is licensed. I hope it's a MIT or BSD-flavored license . . . this would make it easier to work with.
Thanks . . .
It seems that mark_object could be recursively called with large depth, which demands a lot of stack slots.
example code(test.lua):
local snapshot = require "snapshot"
local function create_co()
local co_upvalue = { 1,2,3 }
local co = coroutine.create( function()
for k,v in pairs( co_upvalue ) do
print( k,v )
end
end )
return co
end
local S1 = snapshot()
co = create_co()
local S2 = snapshot()
for k,v in pairs(S2) do
if S1[k] == nil then
print(k,v)
end
end
coroutine.resume( co ) -- test,co_upvalue still in memory
output:
lua test.lua
userdata: 0x10be3e8
0x10ba930 : co
userdata: 0x10c9210 table
0x10ba018 : S1 : test.lua:17
1 1
2 2
3 3
no leak infomation about co_upvalue ?
你好:
我将文件包下载解压后,在centos 7上编译成功,然后直接执行lua dump.lua,出现段错误,没有仔细研究过lua,请问一下是什么原因呢,lua版本是5.1.4
Is there any chance you could back-port this to Lua 5.1? There are still many of us that are stuck at the older version for one reason or another. I tried a quick hack at the code but it appears the snapshot doesn't pick up variables marked as "local".
Thanks . . .
local req_name = "ZoneProtocol.GetSceneItemListReq"
local S1 = snapshot()
pb.encode(req_name, {sceneid=0})
local S2 = snapshot()
for k,v in pairs(S2) do
if S1[k] == nil then
print(k,v)
end
end
输出:
userdata: 0x7f0b21083cc0 table
0x7f0b1fc8b708 : S1 : ...iao/rp_server/pub/test_robot/bin/service/robot_agent.lua:146
userdata: 0x7f0b2101c040 table
0x7f0b1fca2dc0 : ZoneProtocol.GetSceneItemListReq
Why does this code add a variable j?Can the author help explain?
int i,j; for (j=1;j>-1;j-=2) { for (i=j;;i+=j) { const char * name = lua_getlocal(cL, &ar, i); if (name == NULL) break; snprintf(tmp, sizeof(tmp), "%s : %s:%d",name,ar.short_src,ar.currentline); mark_object(cL, dL, t, tmp); } }
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.