How is this animation preloading?

Here is a bit of code from the default Animate script for a character.

	-- preload anims
	for i, animType in pairs(animTable) do
		for idx = 1, animType.count, 1 do
			if PreloadedAnims[animType[idx].anim.AnimationId] == nil then
				PreloadedAnims[animType[idx].anim.AnimationId] = true

I am curious, as to how this is actually preloading the animations?
The part Humanoid:LoadAnimaion() should be returning a track, right?

And since we are not storing the return value, does that mean the track will get GC’d at the end of this function?

Also, considering that elsewhere in the code, tracks are :Destroy(), does that instead mean the tracks are held up in memory somewhere, until the entire script is GC’d?

Thanks for any insight into this.

Make __gc work on tables - #2 por Kampfkarren - Engine Features - DevForum | Roblox

It probably will be.


So they are GC as soon as they are returned with no reference, or at termination of function, or at termination of script?

Considering an AnimationTrack has a reference to the Animation Instance that it was loaded from, does that make any difference, could the Track remain in memory until the Animation Instance is destroyed?

I don’t know this one.

I think it does not remain in memory since the Animation property is simply a pointer to the Instance.