Having 1000+ unions is safe?

Hello, my game currently for a client memory slowly increase till its 1.2gb and our game is using tons of unions so would unions really cause terrible?

image

I am not sure if this script is accurate but it printed 5.6k
image

1 Like

unions do cause lag when there are enough of them but I do not know how many but 1000 of them probably cause lag. YOu can prevent this by exporting the unions as a mesh and then importing the mesh to Roblox.

4 Likes

Alright thank you I will try this

ok make sure to copy the size and position of the union to make it easer when you change them out

1 Like

An important step to include for this is to clean up the Union’s geometry before importing it into Studio. Just converting a Union to a Meshpart as-is has significantly less performance benefits. You have to actually fix the geometry issues that Unions usually have. :slight_smile:


This sounds more like a script issue than one with Unions. When memory use increases during run time, the first place to look is your code. Test by isolating variables: temporarily remove all scripts in your game, and see if memory still increases. If it doesn’t increase without scripts, work through any code for issues. If it does still increase, post a picture of your Memory Use breakdown and we can go from there :smiley:


I also want to mention that while Unions usually aren’t great, and 1000 of them could be a problem, only 1000 of the same Union (or even a mix of a few) will instance fairly well and likely wouldn’t be contributing to such a high memory use impact unless they’re really complex Unions. I would be looking elsewhere for such a high memory use impact before targeting Unions :slight_smile:


Edit

I just noticed your picture says 5000+ Unions not 1000+ like your title. I’d still remove code like I suggested above, because 1000 or 5000 of well instanced Unions still likely wouldn’t cause 1.2gb of Memory Use unless they’re poorly optimized.

7 Likes

1.2 GB? Are you checking this on Studio or In-Game? Studio uses a lot more memory than in-game for some reason.

No not studio, I am checking it on game

1 Like