Actors stay in memory forever

I recently came across an issue with actors in which I found out that they don’t get garbage collected. I’ve attached a place file as showcase.

There is a script in StarterPlayerScripts. If you hit E on the keyboard, it will simulate the actor leaks.
image

LuauHeap examination shows evidence of unnecessary memory usage (all the Actors and scripts are destroyed, so they should not be used in memory):

If this is actually expected behavior, please tell me, but I’m pretty sure that this is a problem.

Place File:
Actor Memory Leaks Example.rbxl (57.4 KB)

  • Step 1) Play and Press F9, and take a LuauHeap snapshot
  • Step 2) Press E on the keyboard
  • Step 3) Wait 5 seconds, then take another LuauHeap snapshot
  • Step 4) You should notice that, despite the actors and scripts being destroyed, they are still being used in memory

Expected behavior

If everything was working correctly, I would expect destroyed Actors to not be used in memory.

2 Likes

Thanks for the report.

This behavior is intentional, VM will wait to run new actors in the future.
We don’t currently have plans to change this behavior.

What should we do to properly deallocate the actors though?

I think they mean that there’s no way to get them to de-allocate, the behaviour is intentional as they will idle until Actors are needed again.

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