Reference API Roblox

Engine API

Website

Related

Reference API Roblox

HeapProfilerService

Generates and retrieves Luau heap memory profiles from the client and server Luau virtual machines for memory debugging.

This class is not creatable. Instances of this class cannot be created with Instance.new.
This class is a service. It is a singleton that may be acquired with GetService.
Tags: [NotCreatable, Service]

Member index 4

HistoryMember
661ClientRequestDataAsync(player: Player): string
661ServerRequestDataAsync(): string
661OnNewData(player: Player, jsonString: buffer, id: int, compressedLength: int, uncompressedLength: int)
inherited from Instance
731Archivable: bool
731Capabilities: SecurityCapabilities
731IsInSandbox: bool
731Name: string
731Parent: Instance
731PredictionMode: PredictionMode
731Sandboxed: bool
731UniqueId: UniqueId
576AddTag(tag: string): null
573ClearAllChildren(): null
462Clone(): Instance
573Destroy(): null
486FindFirstAncestor(name: string): Instance
486FindFirstAncestorOfClass(className: string): Instance
486FindFirstAncestorWhichIsA(className: string): Instance
486FindFirstChild(name: string, recursive: bool = false): Instance
486FindFirstChildOfClass(className: string): Instance
486FindFirstChildWhichIsA(className: string, recursive: bool = false): Instance
486FindFirstDescendant(name: string): Instance
563GetActor(): Actor
486GetAttribute(attribute: string): Variant
462GetAttributeChangedSignal(attribute: string): RBXScriptSignal
631GetAttributes(): Dictionary
648GetChildren(): Instances
462GetDebugId(scopeLength: int = 4): string
707GetDescendants(): Instances
486GetFullName(): string
706GetStyled(name: string, selector: string?): Variant
657GetStyledPropertyChangedSignal(property: string): RBXScriptSignal
576GetTags(): Array
576HasTag(tag: string): bool
486IsAncestorOf(descendant: Instance): bool
486IsDescendantOf(ancestor: Instance): bool
664IsPropertyModified(property: string): bool
698QueryDescendants(selector: string): Instances
573Remove(): null
576RemoveTag(tag: string): null
664ResetPropertyToDefault(property: string): null
573SetAttribute(attribute: string, value: Variant): null
462WaitForChild(childName: string, timeOut: double): Instance
731children(): Instances
731clone(): Instance
731destroy(): null
731findFirstChild(name: string, recursive: bool = false): Instance
731getChildren(): Instances
731isDescendantOf(ancestor: Instance): bool
731remove(): null
462AncestryChanged(child: Instance, parent: Instance)
462AttributeChanged(attribute: string)
462ChildAdded(child: Instance)
462ChildRemoved(child: Instance)
462DescendantAdded(descendant: Instance)
462DescendantRemoving(descendant: Instance)
500Destroying()
657StyledPropertiesChanged()
731childAdded(child: Instance)
inherited from Object
731ClassName: string
731className: string
647GetPropertyChangedSignal(property: string): RBXScriptSignal
647IsA(className: string): bool
731isA(className: string): bool
647Changed(property: string)

Description

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.

History 7

Members 4

ClientRequestDataAsync

Parameters (1)
playerPlayer
Returns (1)
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 through HeapProfilerService.OnNewData, decompressed, and returned. If the client does not respond within 10 seconds, the request fails.

The returned string is JSON containing a Report section (heap memory broken down by value type, memory category, and userdata class, plus an aggregated size graph) and a Refs section (unique and unparented instance references).

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

OnNewData

Parameters (5)
playerPlayer
jsonStringbuffer
idint
compressedLengthint
uncompressedLengthint

Delivers a Luau heap profile that was generated on a remote machine in response to a HeapProfilerService:ClientRequestDataAsync() or HeapProfilerService:ServerRequestDataAsync() call. The profile JSON is zstd-compressed and carried in jsonString; the receiving service decompresses it, matches it to the pending request by id, and resolves the yielding call. The compressedLength and uncompressedLength arguments report the buffer's size before and after decompression.

History 1

ServerRequestDataAsync

Parameters (0)
No parameters.
Returns (1)
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().

This function yields. It will block the calling thread until completion.

History 1

Tags: [Yields]

Settings