Is there a way to put an instance into a low-memory state?

I’m creating a chunking system, and instead of completely deleting an instance once it’s been created, I’d like to instead save it in a state that uses up as little resources as possible (reduce memory usage, stop physics calculations, etc.). Is there a way to do this? I’m looking for the equivalent of Unity’s .activeSelf.

2 Likes

Is re-parenting the instance to ServerStorage or ReplicatedStorage a good idea? It would deffintely take way more less memory since it’s no longer visible and if any scripts are included they won’t run.

2 Likes

That’s what I assumed. I don’t think physics calculations are done in ReplicatedStorage, so that’s probably the way to go. If anyone has any further insight into this, I’d appreciate it.

2 Likes

I saw this post a while back but haven’t done any experimenting to it’s affect yet.

Basically what I gather is that setting the CFraming of objects to a far away location, is more performant than changing ancestry, or re-parenting.

3 Likes

An option would be setting the instance’s parent to nil and then reassigning it to a DataModel descendant once you need the instance again. This way, it will not interfere with other stuff until you want it to.

You should change any objects’ properties, if possible, while they have a nil ancestor for optimal performance results.

Note: Any events prevously connected to that instance would have to be manually disconnected.

1 Like

Just curious. Is there a reason streaming can’t solve your problem?

1 Like

The world is broken up into chunks. My code relies on the entire chunk being available, and since there’s no way to stream in/out entire models at a time, there’d be no way to ensure that the entire chunk was available. Additionally, this chunking system avoids the high network activity that streaming causes, and since chunks are being loaded in very often, that’d cripple the player experience significantly.

1 Like