# Unable to unload async-loaded textures in a widget

**URL:** <https://forums.unrealengine.com/t/unable-to-unload-async-loaded-textures-in-a-widget/401077>\
**Category:** UI\
**Tags:** garbage-collector, asynchronous-asset-l, unreal-engine, memory, Widget, question\
**Created:** [August 3, 2017, 3:53am UTC](https://forums.unrealengine.com/t/unable-to-unload-async-loaded-textures-in-a-widget/401077 "2017-08-03T03:53:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spoondog](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Spoondog](https://forums.unrealengine.com/u/Spoondog)\
**Post date:** [August 3, 2017, 3:53am UTC](https://forums.unrealengine.com/t/unable-to-unload-async-loaded-textures-in-a-widget/401077/1 "2017-08-03T03:53:26Z")

</div>

In UE4.16.3, I am async-loading textures for UI purposes, since I don’t want full-res UI textures sitting in memory all the time. This works well (I use OBJ LIST to see what textures are loaded before and after the load). The UI widget will async-load a data table (via asset ID) that references the asset IDs of various UI textures, which then get loaded as necessary.

However, I am unable to find any way (in Blueprint) to then remove these loaded textures from memory. User Widgets stay in memory when removed from the viewport, even after a garbage collect, so I tried de-referencing the async-loaded UI textures from the image widgets (when the UI is removed from the viewport), but after a garbage collect, the textures are still in memory.

As far as I can see, it seems like any async-loaded assets will just have to stay in memory? (unless you are using C++)

The only workaround I can think of is to use mip-maps on UI textures, and assume that the texture streaming system will keep only the smallest mip in memory when the UI is not in view. But requiring mip-maps for UI textures comes with other issues…

EDIT: Here is an example of what I’m doing:

 ![203578-asyncloaduitex.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/2/a/32af5c7f56edbdc63e9b5ea1d1ba6be68265ad06.png)

---

<div class="post-metadata">

**Author:** ![Spoondog](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Spoondog](https://forums.unrealengine.com/u/Spoondog)\
**Post date:** [August 3, 2017, 4:40am UTC](https://forums.unrealengine.com/t/unable-to-unload-async-loaded-textures-in-a-widget/401077/2 "2017-08-03T04:40:57Z")

</div>

Just doing some more testing to see if I’ve de-referenced the texture properly:

OBJ REFS says that the texture is still referenced by a “Cast to Texture2D” node (that is inside that “Load Image for Key” macro). Perhaps this is the real problem - references are being held by a blueprint node that has long finished executing…

---

<div class="post-metadata">

**Author:** ![Spoondog](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Spoondog](https://forums.unrealengine.com/u/Spoondog)\
**Post date:** [August 3, 2017, 5:11am UTC](https://forums.unrealengine.com/t/unable-to-unload-async-loaded-textures-in-a-widget/401077/3 "2017-08-03T05:11:22Z")

</div>

Ah, ok - the texture reference is actually held due to this problem:

> **[Lingering object references from event graph pins](https://forums.unrealengine.com/questions/372332/lingering-object-references-from-event-graph-pins.html)**
>
> Not sure if this is a bug as such, but it's rather hidden and definitely has potential to cause issues. I was trying to find out why one of my objects was not being destroyed when I expected it to be. Using the obj refs name= console commend I...

I hope that is on the issues radar somewhere… potentially huge assets could be held in memory just because of a blueprint node that got executed a long time ago…

---

<div class="post-metadata">

**Author:** ![Spoondog](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Spoondog](https://forums.unrealengine.com/u/Spoondog)\
**Post date:** [August 3, 2017, 6:06am UTC](https://forums.unrealengine.com/t/unable-to-unload-async-loaded-textures-in-a-widget/401077/4 "2017-08-03T06:06:28Z")

</div>

I made an updated post about the blueprint object references here:

> **[Blueprint node pins hold object references indefinitely](https://forums.unrealengine.com/questions/677168/blueprint-node-pins-hold-object-references-indefin.html)**
>
> So this doesn't prevent, say, a character from getting destroyed- but anything which can't be explicitly destroyed is kept in memory instead? Definitely explains some things I haven't nailed down but have observed.
