Parenting to nil vs making visible false

Hello!

I was wondering if parenting an image label to nil is more performant than just setting its visible property to nil? I am planning on having potentially hundreds to thousands of image labels and I really just need to know whether parenting the image label to nil is more performant than setting their visible property to false?

definately dont take my word for it but i believe that with images parenting to nill will do better than just making transparency 0. Depending where you put it that is. For example in server storage it wont take space on the clients device but it will for the server. Its just an image so im not sure that its really that big of a deal.

1 Like

It definitely is a big deal, for me at least. I’ve had like 3,000 image labels and it caused frames to drop instantly upon tweening the frame.

I also can’t parent it to server storage because I’m using a local script.

I’m also not making its transparency to 1, I’m setting the visible property to false.

oh, why so many?
do you think you can share the game so i can check it out?

i see let me look at the developer site. Im inexperienced with images and guis

I am making a shop and I’m giving the players the option to purchase accessories if they want to.

And no, I can’t share it as it’s not ready to be released. Sorry.

it’d only be the few devs that see it here but if that doesnt change your mind then thats cool.

I did some reading and am alittle more confident that parenting to nil is more efficient becuase it takes the object out of the game entirely. The visible property however only stops the image from being rendered. The GUI object is still in the game when visible is set to false.

I saw a post awhile back that might be beneficial to you, although I can’t find it. The idea is similar to frustrum culling that Roblox does behind the scenes. If you don’t already know what that is, essentially the only instances on your client that are loaded are the ones that your camera has view of. This video is a good example of how it works.

The post had a similar approach to UIObjects under a ScrollingFrame. Instead of hundreds or thousands of frames being under that UI, only a select few were loaded at a time depending on where you were along that scroll wheel.

I’ll edit this reply if I can find the post.

Do you need to keep them in storage? Why not just use :Destroy() or parent them to Debris?

If you can, try benchmarking it with a bunch of elements. If there’s any performance gain from changing properties I would guess it’s from maybe some connections being disconnected when you parent to nil, but I don’t think that happens at all.

Sadly instances are just expensive to work with.

You mean add to Debris…? I don’t think that’s relevant here, he probably wants to reuse them, or has them deactivated and activated rapidly. Creating instances is a bit expensive as well.

1 Like

Yeah, Debris:AddItem(), and you’re right checking the thread it seems they want the instances to remain active just hidden. I’d assume setting the “Visible” property to false would be better since if they are parented to nil then they would still be rendered.

1 Like

Yeah, I kinda made the assumption that they weren’t rendered unless on-screen as that was the only time that image labels could fail to load, however it becomes problematic when I have a bunch of frames that have their visible property set to false, particularly when tweening a frame as it causes frames to drop which sucks. I don’t think image labels are rendered when they’re not visible in a ScrollingFrame either though.

@LucasMZ_RBX, I’ll try benchmarking, good idea.

@Limited_Unique, I need access to the image labels, I can’t just destroy them or add them to debris. Also as NoParameters said, they are only rendered if on-screen, so parenting them to nil shouldn’t render them.

Here are my findings based on the benchmarks, I tried around 1,100 frames, all of which have two 600x600 images and a single UIGradient:

Parenting to nil:
~22.4mb

Visible false:
~21.8mb

So visible false seems to be the way to go.

Perhaps this is because if visible is false the other properties are ignored whereas if the image is parented to nil then those other properties are still considered relevant/necessary.