Making a memory visualizer/profiler with luau #2048
-
|
Greetings! I've managed to get some very general info (total memory used/freed, total allocations amount) via a custom allocator function. There also seems to be C api for retrieving total bytes per type (lua_setmemcat, lua_totalbytes). I'm totally stuck on how to proceed from here. How would one approach this (and is it even possible to make something similar without modifying source)? If there's an open source implementation of something like this, please share it :) (the ones I've look at were quite bare-bones). Any help at all would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
|
Hello! The main function used in those tools is For an open-source implementation, it is also similar to the way Finally, you can use We have plans to make these |
Beta Was this translation helpful? Give feedback.
-
|
Okay, got it to work finally. That's sooo powerful!!!! Luau rocks ❤️ |
Beta Was this translation helpful? Give feedback.
Hello!
The main function used in those tools is
luaC_enumheap, you can use that to build a whole graph of objects in memory.For an open-source implementation, it is also similar to the way
luaC_dumpgenerates a JSON file you can send into https://github.com/luau-lang/luau/blob/master/tools/perfstat.py and https://github.com/luau-lang/luau/blob/master/tools/perfgraph.pyFinally, you can use
lua_callbacksandonallocatecallback to collect information on call stack of every allocation (expensive for performance, but useful for other kinds of analysis).We have plans to make these
luaC_*functions a part of the public C API in the future, but our roadmap is filled with other things for now.