Service · inherits Instance
HeapProfilerService
Generates and retrieves Luau heap memory profiles from the client and server Luau virtual machines for memory debugging.
About HeapProfilerService
HeapProfilerService captures snapshots of the Luau heap so that
memory-profiling tools can analyze script memory usage. Requesting a profile
runs a full garbage-collection cycle and then walks the heap of the target
Luau virtual machine, producing a JSON report that breaks memory down by value
type, memory category, and userdata class, together with an aggregated
ownership graph and a list of unique and unparented instance references.
Profiles can be requested for either the server or a specific client.
HeapProfilerService.ServerRequestDataAsync returns the server's
profile and HeapProfilerService.ClientRequestDataAsync returns a
given player's client profile. When the profiled machine differs from the
caller, the data is generated remotely, compressed, and replicated back
through the HeapProfilerService.OnNewData event before the yielding
call resolves.
Methods 2
ClientRequestDataAsync
(player: Player) → stringYieldsPluginYields until the Luau heap profile of the specified player's client is available, then returns it as a JSON string.Requests a Luau heap profile from the client belonging to
player. When called on that client itself, the profile is generated locally and returned immediately. When called from the server, a request is sent to the client and this function yields until the compressed profile is replicated back throughHeapProfilerService.OnNewData, decompressed, and returned. If the client does not respond within 10 seconds, the request fails.The returned string is JSON containing a
Reportsection (heap memory broken down by value type, memory category, and userdata class, plus an aggregated size graph) and aRefssection (unique and unparented instance references).ServerRequestDataAsync
() → stringYieldsPluginYields until the server's Luau heap profile is available, then returns it as a JSON string.Requests a Luau heap profile from the server. When called on the server, the profile is generated locally and returned immediately. When called from a client, a request is sent to the server and this function yields until the compressed profile is replicated back through
HeapProfilerService.OnNewData, decompressed, and returned. If the server does not respond within 10 seconds, the request fails.The returned string has the same JSON structure as
HeapProfilerService.ClientRequestDataAsync.
Events 1
OnNewData
HeapProfilerService.OnNewData:Connect(function(player, jsonString, id, compressedLength, uncompressedLength))PluginFires on the requesting machine with the compressed Luau heap profile produced for an earlier request.Delivers a Luau heap profile that was generated on a remote machine in response to a
HeapProfilerService.ClientRequestDataAsyncorHeapProfilerService.ServerRequestDataAsynccall. The profile JSON is zstd-compressed and carried injsonString; the receiving service decompresses it, matches it to the pending request byid, and resolves the yielding call. ThecompressedLengthanduncompressedLengtharguments report the buffer's size before and after decompression.
HeapProfilerService also has every member of Instance. Deprecated and Roblox-only members are hidden.
Reference text from the Roblox Creator Documentation, licensed CC BY 4.0, reorganized by rbxtoolshub.com · Studio 0.743.0.7431133.