Will calling a table as a parameter with instances cause a memory leak?

Let’s say for example I have a module that calls another module with a character model in the parameter like this:

--First module:

function ModuleOne:DoThis()
      ModuleTwo:DoThat({Character1, Character2})
end

--Second Module

function ModuleTwo:DoThat(CharacterList)

end

Will doing this cause any memory leaks if the character gets destroyed and cannot get GC’ed because it is referenced in a table. If so will it only happen in the first module or second module or both, so would I need to loop over the table and set all the indexes to nil?

The table is going to be garbage collected once ModuleTwo:DoThat finished execution. There is no other way to reference it. So this case wouldn’t leak memory.

1 Like

This wouldn’t cause a memorly leak or anything of that sort. You’re just adding a table as one of the parameters. You can do anything you want with the table after you reference it in the second function.