Allow developers access to user-defined Memory Tags

Problem
Currently, there are still not enough tools for us to properly track down memory leaks.

Right now, we can determine automatically that there is a potential leak using the existing API GetMemoryUsageMbForTag. But we cannot granularly determine what is causing it and where, only the fact that the Lua heap is rising.

We can use the developer console to view individual scripts and custom memory tags, but the developer console uses StatsItems under game:GetService("Stats").PerformanceStats.Memory.PlaceScriptMemory which have functions that are inaccessible to us.

We are able to create our own memory tag definitions under the memory stats in Dev Console using debug.setmemorycategory(), such as the examples in this screenshot.

We can view this on a live game, but we cannot programmatically access them with scripts.

Request
It would be nice if we could track those individual memory stats for ourselves in order to trace down potential memory leaks. For example, if we were able to query these ourselves, we could set up analytics for automatic memory leak detection for debugging.

It is not practical for us to constantly sit in a lobby trying to figure out what grows overtime, but this is basically our only current solution to finding and guessing where memory leaks may be.

Roblox themselves can access this data using StatsItems as value holders as shown below

But we cannot access this as developers because they are a protected instance
image

Ideally, we can get our own version of this API something along the lines of StatsService:GetCustomMemoryCategories() so that we can access this with scripts.

18 Likes

I totally agree with this, because looking at all those stacked memory categories hurts my eyes. It’s very hard to read and I don’t get how people put up with it, so I don’t use it.

Do you think there would be any recursive behavior when getting the amount of memory in a script? Like, getting all the memory categories might indirectly increase memory because of the new data being remembered. Or maybe I’m overthinking it a little.

Bumping this. I’d like to automatically track memory leaks over long periods of time, however that’s not possible because of this oversight.

1 Like

How do you use the Feature Requests tag?

Memory tracking utilities are definitely not able to be used reliably as they are designed right now. I can barely even call it a design, as there’s only one developer-facing function. The addition of a single “read tag” function would be immensely helpful.

1 Like