Do you need to destroy animations loaded with "Anim:LoadAnimation()"

The title basically explains it all. But if you still dont get it. Basically…

I recently noticed that LoadAnimation() has a destroy method. Does this mean i need to destroy the loaded one everythime i dont need it?? i know you need to destroy the actual animation instance. But the loaded ones im a bit worried about?

Am i just being too paranoid about nothing or does this count as a memory leak :sweat_smile:??

I haven’t noticed a difference in using AnimationTrack:Destroy(), even after I call for it to be destoryed, it’s useable.

I don’t think that really affects anything, but you can’t overload Roblox with animations - so this is pretty useless. No memory leaks.

1 Like

AnimationTracks are still instances so they adhere to the same principles as other instances - that is, don’t hold strong references if you don’t want memory leaks. You should be destroying AnimationTracks if you don’t need them anymore. Connections and other strong references to the track can keep the instance alive when you don’t want.

The sample in the OP shouldn’t leak memory because when the scope closes the local variable is cleaned up and there’s no more references to the AnimationTrack.

2 Likes

AnimationTrack (usually) barely weights anything - this doesn’t really affect Roblox, except scenarios when you have many animations loaded (I mean not just 50 or 70, but more than 130 - I tested, this started affecting my RAM and GPU very much).
But Roblox server themselves are pretty strong to hold this much resources idk if i wrote this correct - plus the fact they have optimization.

1 Like

Doesn’t matter really. Most instances and other memory-consuming entities in the engine don’t cost that much alone. It’s not the individual instances that you need to think about but the overall picture and everything added together. Memory leaks are a summary of all memory management problems not necessarily owed to a single type of instance. That and it’s good practice to destroy instances you don’t need anymore regardless. Optimisation, available memory and the cost of instances don’t play a factor in good practice and taking proper steps to manage your instances.

1 Like

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