samc
Topic Author
Posts: 94
Joined: 21 Aug 2019, 19:22

Question about textures from loaded XAML files

18 Nov 2024, 21:03

Suppose I have a XAML file that has a very large full screen background texture. That Xaml is my loading image that is used when launching the game.

Once that xaml is removed, is the texture memory associated with that huge background texture also supposed to be freed?

I might be mistaken, but it looks like right now that huge texture is staying resident, even though it's not used and no xaml is actively referencing it. Is there a recommendation here? It seems like I could probably do the texture through a data binding and then manage the memory myself, but I imagine this is a pretty common case, so I was curious what the recommendation is.

thanks,
sam
 
User avatar
jsantos
Site Admin
Posts: 4822
Joined: 20 Jan 2012, 17:18
Contact:

Re: Question about textures from loaded XAML files

19 Nov 2024, 21:08

Once that xaml is removed, is the texture memory associated with that huge background texture also supposed to be freed?
XAML assets retain references to the textures they use. When a XAML asset is unloaded, Unity may also unload the associated texture asset.

If you need more explicit control over this behavior, consider using Unity's Addressables system. Many of our clients use Addressables to manage such dependencies effectively. Have you explored this approach before?
 
User avatar
maherne
Site Admin
Posts: 53
Joined: 01 Jul 2022, 10:10

Re: Question about textures from loaded XAML files

20 Nov 2024, 14:04

As Jesús mentioned, Addressables is an effective way of managing assets in your UI.

There is an AddressablesImage control on the Showcase forum which loads an Addressable texture when the control is loaded, and releases the asset when the control is unloaded. You can find that here: viewtopic.php?t=2629

Who is online

Users browsing this forum: No registered users and 4 guests