Hi developers,
Our in-game Developer Console displays a lot of data that can be used to improve performance of your experiences. And if you’ve ever used the Memory section, you would have seen the amount of memory used by different Roblox system components, but Luau script memory was only being collected into a single row.
In a recent update, we have improved the information available about Luau scripts and memory that is in use by different Luau threads to help track down issues - such as memory leaks.
We have added two new category groups: PlaceScriptMemory and CoreScriptMemory. The values for each row are displayed in megabytes and you can click on a row to see a recent history graph for that value.
Keep in mind that scripts are running on Client and on Server, so use the tabs at the top to select which memory statistic you want to view.
By default, when Luau thread is created to run a script, allocations performed by that thread will be assigned a tag that is based on the script name. By using the new debug
library functions, it is possible to control the associated memory tag value:
-
debug.setmemorycategory(string)
will assign a custom tag name to the thread -
debug.resetmemorycategory()
will reset the tag to the auto-assigned value
You can assign a custom memory category to the thread once at the start or use the combination of two functions to test memory allocations of a specific part of code.
If your script spawns additional Luau threads, they will inherit the memory tag value.
Two final things to note:
To keep the overhead of memory tags extremely low, there are implementation-defined limits for the amount of script and user memory tags. Because of this, you might see a single row sharing more than one script/tag name.
Keep in mind that a Luau thread has an associated memory tag and not the specific script instance. If your script calls a function defined in ModuleScript, allocations made there will be tracked by the calling script thread.