Do instances parented to nil occupy memory?

I’d like to know if instances that are parented to nil occupy memory or not. Since in my game I made some instances parent to nil (for some special cases) when they aren’t used by the player. However, if the player leaves, those instances will always be parented to nil. Do they occupy memory or they won’t cause any problem? Especially in long term, if there are 300-400 instances parented to nil could they create server lag?

1 Like

Short answer, yes they do.

As far as I’m aware, if you parent it to nil, it’s pretty much the same as parenting it to anything else (correct me if I’m wrong here).

I’d suggest deleting these instances when a player leaves, as one instance wouldn’t cause much issues, but multiple may start to cause issues with rendering and stuff.

The garbage collector should destroy these after some time, if they are unused, but it’s still best to destroy it when the player leaves, just to prevent further issues.

3 Likes