Lua memory (de)allocation tracer: (#5191)
* Lua memory (de)allocation tracer: Usage: * turn on: `cmake -DLUA=YES -DLUA_ALLOCATOR_TRACER=YES -DDEBUG=YES -DNANO=NO` * get debug output and make plot data: `./simu 2>&1 | grep "^LT" | ../radio/util/lua_trace2plot.py > data.plot` * plot: `gnuplot -e 'set xtics rotate; plot "data.plot" using 2:xtic(1) ; pause mouse close'` * Changes based on Bertrand comments
This commit is contained in:
committed by
Bertrand Songis
parent
c30ff28f85
commit
f0f3e35bf6
@@ -514,12 +514,20 @@ void luaLoadFiles(const char * directory, void (*callback)())
|
||||
f_closedir(&dir);
|
||||
}
|
||||
|
||||
#if defined(LUA_ALLOCATOR_TRACER)
|
||||
LuaMemTracer lsWidgetsTrace;
|
||||
#endif
|
||||
|
||||
void luaInitThemesAndWidgets()
|
||||
{
|
||||
TRACE("luaInitThemesAndWidgets");
|
||||
|
||||
#if defined(USE_BIN_ALLOCATOR)
|
||||
lsWidgets = lua_newstate(bin_l_alloc, NULL); //we use our own allocator!
|
||||
#elif defined(LUA_ALLOCATOR_TRACER)
|
||||
memset(&lsWidgetsTrace, 0 , sizeof(lsWidgetsTrace));
|
||||
lsWidgetsTrace.script = "lua_newstate(widgets)";
|
||||
lsWidgets = lua_newstate(tracer_alloc, &lsWidgetsTrace); //we use tracer allocator
|
||||
#else
|
||||
lsWidgets = lua_newstate(l_alloc, NULL); //we use Lua default allocator
|
||||
#endif
|
||||
@@ -527,6 +535,10 @@ void luaInitThemesAndWidgets()
|
||||
// install our panic handler
|
||||
lua_atpanic(lsWidgets, &custom_lua_atpanic);
|
||||
|
||||
#if defined(LUA_ALLOCATOR_TRACER)
|
||||
lua_sethook(lsWidgets, luaHook, LUA_MASKLINE, 0);
|
||||
#endif
|
||||
|
||||
// protect libs and constants registration
|
||||
PROTECT_LUA() {
|
||||
luaRegisterLibraries(lsWidgets);
|
||||
|
||||
Reference in New Issue
Block a user