Destroy() does not decrease memory usage?

Seems a bit weird, would be pretty nice to get a function that’s basically destroy and actually performs as one would expect it to.

Using ViewportFrames ( instead of an image for each single item should reduce your memory usage a lot.

It does clone back the script afterwards.

Before the MenuButton is pressed:

After the MenuButton is pressed:

After opening some GUIs:

After closing them, the MenuScript is cloned back and the other GUIs that were opened are no longer under PlayerGui;

:frowning: It is really weird that Destroy() doesn’t just wipe everything, from memory caching onward.

Another important factor is that images with high resolutions will eat your memory easily. If your image has maximum pixels of 1024² and it is used as a small icon, definitely should be replacing it.

1 Like

If I’m following you correctly,

-- all the GUI variables
GUIs:Destroy() -- wouldn't I be destroying them before I need to here?

while wait() do
-- Clone the GUIs

Wouldn’t using Destroy() when closing the Menus prevent all the memory leaking because it should have wiped the Guis from the PlayerGui, and when I clone the MenuScript back it should start fresh?

I’d like to have this topic resurface since I’m facing the same exact issue as the OP. No one seemed to have a viable answer to this topic that helped the OP, so I really hope this time someone could give some clarification on what to do about decreasing the memory usage of GraphicsTextures after they are no longer in use by the client rather than having that memory linger around.

There is a solution to this from the looks of it, since after doing a bit of investigating to see if it is possible, it seems like Royale High achieved this.

I highlighted the GraphicsTexture to show what the amount was without any UI elements showing. It is at around 119 MB.

After scrolling through a list of UIs, the memory spiked up to around 142 MB in GraphicsTexture.

Then when I clicked on a button that had just one UI element, the GraphicsTexture went down to 121 MB.

So please, if anyone could explain how this was done, I’d really appreciate it.

I’d also like to include a neat little method which I think could vastly help with reducing GraphicsTexture memory for the OP without having to fiddle around with scripts. It is very time consuming, but the results are amazing.

So if you were to make a spritesheet of the images you use in-game, then you could use this plugin to easily crop out different sections rather than having to manually adjust the RectOffset and RectSize properties of the specific locations of the spritesheet you wish to use. After you make a selection, you could instantly create an ImageButton or ImageLabel out of it.

In other words, this means that you could use one image ID for a multitude of assets used in-game which in turn would definitely save from memory costs.

1 Like