Do copies of a package script share the same bytecode in memory or is it duplicated?

I was wondering if multiple instances of a package script would point to the same bytecode in memory, or would they each have their own bytecode that is synced. Thanks!

I’m not sure if this is what you’re talking about.

But when you require a ModuleScript in game, and then require it again from another script, they will reference the same script as it caches.

Not exactly; they only share environment if the scripts are of the same execution level and are both thread-synchronized

I guess cached isn’t the right word to use there.

Here’s a screenshot from the developer hub.

No, multiple instances of a package script will not point to the same bytecode in memory. Each instance will have its own bytecode that is generated and then stored in memory.

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