Lua Tools - yszheda/wiki GitHub Wiki
Profiler
- http://stackoverflow.com/questions/15725744/easy-lua-profiling
- https://github.com/mindreframer/ProFi.lua
- https://www.lua.org/wshop15/Musa2.pdf
Memory Usage
- http://hekad.readthedocs.io/en/v0.10.0/config/filters/mem_stats.html
- http://code.matthewwild.co.uk/lua-getsize/file/fcb41eb42326/getsize.c
- http://lua.2524044.n2.nabble.com/Tracking-memory-usage-td7642181.html
Memory Leak Checker
snapshot
- http://blog.codingnow.com/2012/12/lua_snapshot.html
- http://www.codingart.info/snapshot-detect-Lua-memoryleak.html
-
copy snapshot source code to:
frameworks/cocos2d-x/external/lua/lua-snapshot
-
frameworks/cocos2d-x/cocos/scripting/lua-bindings/manual/lua-snapshot/lua_extensions.c
:
#include "lua_extensions.h"
#if __cplusplus
extern "C" {
#endif
// snapshot
#include "lua-snapshot/snapshot.h"
static luaL_Reg luax_exts[] = {
{"snapshot", luaopen_snapshot},
{NULL, NULL}
};
void luaopen_lua_extensions(lua_State *L)
{
// load extensions
luaL_Reg* lib = luax_exts;
lua_getglobal(L, "package");
lua_getfield(L, -1, "preload");
for (; lib->func; lib++)
{
lua_pushcfunction(L, lib->func);
lua_setfield(L, -2, lib->name);
}
lua_pop(L, 2);
}
#if __cplusplus
} // extern "C"
#endif
c++ leak
dmalloc_debug_setup("log-stats,log-non-free,check-fence,log=logfile");
dmalloc_log_stats();
dmalloc_log_unfreed();
gdb txos pid -batch -x "gdb cmd file"
参考资料
- Dmalloc : http://dmalloc.com/
- Debugging Memory Errors in C/C++ : http://www.cs.berkeley.edu/~smcpeak/memory-errors/
- http://www.andreasen.org/LeakTracer/README.html c++ new/delete leakage trace
- http://valgrind.org/ for linux
valgrind --leak-check=yes --show-reachable=yes --tool=memcheck --num-callers=30 your_prog_and_arg