Memory leak when cloning humanoids (With repro place file attached)

Found a memory leak when cloning humanoids.
Repro script (which should be run as a localscript…)

while game.Players.LocalPlayer.Character == nil do wait(0.1) end

game.Players.LocalPlayer.Character.Archivable = true
local clone_proto = game.Players.LocalPlayer.Character:Clone()
game.Players.LocalPlayer.Character.Archivable = false
clone_proto.Parent = nil
clone_proto.Archivable = true

while true do
local clone = clone_proto:Clone()
clone.Parent = game.Workspace

local obj_character_desc = clone.Humanoid:GetAppliedDescription()
obj_character_desc.DepthScale = 0.5
obj_character_desc.HeadScale = 0.6
obj_character_desc.HeightScale = 0.7
obj_character_desc.ProportionScale = 0.8
obj_character_desc.WidthScale = 0.9
clone.Humanoid:ApplyDescription(obj_character_desc)

wait()

clone:Destroy()
clone.Parent = nil

print(“Instances:”,game:GetService(“Stats”).InstanceCount, “Instance Memory:”, game:GetService(“Stats”):GetMemoryUsageMbForTag(Enum.DeveloperMemoryTag.Instances))

wait()
end

The humanoid description/scale stuff isn’t necessary (happens without those lines), but does make the memory leak go faster.

Place file:
clone_character_memory_leak.rbxl (53.2 KB)

Memory at start of run…

Memory after ~4 mins soak…

Instance count and memory usage continue to grow.

Expected behavior

Should not leak memory and/or garbage collect larger amounts more consistently.

4 Likes

Hello.

We didn’t find any memory leaks here, instances are eventually collected by Luau GC.

Unless there is an issue actually impacting stability of games, we do not plan to make any changes in current behavior.

Ran it again for an extended period of time and looks like you are right. We’re running into issues doing something similar in our game (that is crashing in mobile devices), but there are likely some other factors. I’ll open another report when it is narrowed down.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.