Cloning humanoid causes memory leak

  1. What do you want to achieve? Keep it simple and clear!
    I was doing some testing and I found cloning a dummy with a humanoid in it causes a memory leak. I was wondering how I could fix this issue since I clone the character in my game to create a decoy effect and I need the humanoid to simulate the health bar and regular movement.

  2. What is the issue? Include screenshots / videos if possible!
    Dummy with humanoid:

Dummy without humanoid:

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried destroying the humanoid before destroying the model but it didn’t change anything.

As a side note, this is all done on the server


the NoHumanoid line should cause an error if it actually has no humanoid in it you cannot :Destroy() it.

i posted the wrong code my bad i will update the image

Does the memory stabilize at any point?

No I’ve tried stopping the loop after a minute and it just stays flat

I tried testing the first scenario with the humanoid, but the memory seems to ramp up before going back down, like a sawtooth. Are you sure nothing else is happening?

yes this is the only script in the game, its happening with both physics part and instances and the script is in serverscriptservice. Also when i do this my ping and recv are really high for some reason

I do see the memory leak with physics parts, but instances doesn’t seem to rise that much. Granted, I am testing in studio, not a real game. If this is a real game, would you mind making it public and sharing the link?

Sure here it is Memory Leak testing - Roblox

If they were to make it public, how would you access the server memory without having developer access?

I made the experience copyable

Make sure to set the dummy variable to nil as well.

This did not change anything for me unfortunately

The dummy variable will automatically be unassigned as it is local in the loop. This is unnecessary.

Even if it was outside of the loop, it would be overwritten with another dummy.

Ofcourse it will do a huge memory leak since you’re infinitely looping the clone thing, plus humanoid itself takes a lot memory

Why doesn’t the 2nd scenario not also memory leak based on your first statement

You’re looping cloning inside the function

1 Like

I’m not sure about the server, but instances on the client seems to climb. However, physicsparts seems to fluctuate. It might be worth messaging someone from @Bug-Support with the place file. Just make sure it is absolutely this script that is causing it.

I’m not seeing the memory leak

here is my project
CloneDummy.rbxl (45.1 KB)

and this is what my memory looks like


I think it is just games I publish then this is what mine looks like using that project

I will file a bug report instead