Just a quick question which I kinda had a brainfart on.
If I clone a model (in this case a Player’s Character), and store it in a table, and then Model:Destroy() is called, will the table still hold a reference to this Model, and will it memory leak?
It erases connections, yes, but I’m storing a reference to the model not a connection
I believe:Destroy() just parents to nil at the end? So isn’t the model technically in the game, and therefore there would still be a reference to it and it wouldn’t GC?
Table basically is:
{
[Player.UserId] = Player.Character:Clone()
}
And then I plan to use the “FakeCharacter” and put it in the DebrisService to clean up if unused. Will a reference still exist, causing a memory leak?
This is incorrect. All that Instance:Destroy does is set the parent of the instance to nil, lock the parent property, disconnect all connections and call Instance:Destroy on all children.