What happens to uncaptured loaded animations?

Let’s say I do this:

local anim1: Animation = ...
local anim2: Animation = ...

animator:LoadAnimation(anim1) -- Line 4
local track = animator:LoadAnimation(anim2)

So what exactly happens to the animation I loaded without capturing (line 4), does it clog the animator causing a memory leak or does it get garbage collected and I shouldn’t be concerned?

1 Like

Yes it does. You can log animations with .AnimationPlayed()

I think loading the same animation just replaces the old one. I’m not 100% sure. Run a loop and see it prints out you hit the animation track limit

Presumably it would be garbage collected as you’ve not assigned it to any variable thus the loaded AnimationTrack instance would have no strong references that point/refer to it.

The 256 track limit is how many tracks can be played at once, not how many tracks can be loaded into one animator at once, you can test this by running a loop more than 256 times without playing the loaded animation and you wouldn’t error.

So I am pretty sure it doesn’t get garbage collected and instead just stays there, so i’ll make sure to cache any animations I load into the animator in case I want to reload them.