# Destroy widget/garbage collection

**URL:** <https://forums.unrealengine.com/t/destroy-widget-garbage-collection/449817>\
**Category:** UI\
**Tags:** garbage-collection, unreal-engine, Widget, question\
**Created:** [May 29, 2019, 9:48pm UTC](https://forums.unrealengine.com/t/destroy-widget-garbage-collection/449817 "2019-05-29T21:48:28Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Claudiu.Schwartz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Claudiu.Schwartz](https://forums.unrealengine.com/u/Claudiu.Schwartz)\
**Post date:** [May 29, 2019, 9:48pm UTC](https://forums.unrealengine.com/t/destroy-widget-garbage-collection/449817/1 "2019-05-29T21:48:28Z")

</div>

I know this question was asked too many times to count, but the “latest” discussions about the topic I’ve found are about two years old, with many engine updates in between so, my questions are:

1. How to destroy widgets in order to avoid memory leaks;
2. Is garbage collection handling widgets when removed from parent and if it does, how often does it destroy them - is it a timer/based on a certain memory threshold/or a certain number of widgets?

Thanks!

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [May 29, 2019, 10:07pm UTC](https://forums.unrealengine.com/t/destroy-widget-garbage-collection/449817/2 "2019-05-29T22:07:44Z")

</div>

The latest discussion on this was actually earlier this month. Here is the link to that question.

> **[Does Garbage Collection handle Widgets that have been removed from it's parent?](https://forums.unrealengine.com/questions/439191/does-garbage-collection-handle-widgets-that-have-b.html)**
>
> I was comparing two floating combat text solutions from the Marketplace: Floating Combat Text and Status Effect and Combat Text Floating Combat Text keeps an array of combat text widgets and reuses them by enabling and disabling them, and changing...

The post is old, but the 2 comments are from May and I also provide a link in that comment to a VERY in depth discussion I and 2 others had on this topic back in February of 2019. That link is here:

> **[Floating combat text and memory/widget destruction?](https://forums.unrealengine.com/questions/877146/floating-combat-text-and-memorywidget-destruction.html)**
>
> Hello, I've made a system for floating combat text, but I am a little worried that this will cause issues with memory. As it stands, every time the player or an enemy receives damage a simple widget displaying the damage value (as well as effects...

Long story short: if you want to remove the widgets from memory you must manually call “collect garbage”. Otherwise they stay in memory for the duration of the level.

---

<div class="post-metadata">

**Author:** ![Crowley\_Caine](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Crowley\_Caine](https://forums.unrealengine.com/u/Crowley_Caine)\
**Post date:** [May 30, 2019, 4:39pm UTC](https://forums.unrealengine.com/t/destroy-widget-garbage-collection/449817/3 "2019-05-30T16:39:59Z")

</div>

This is a link to a thread where we figured it out. It is a bit heavy though so don’t wanna spam that command.

> **[Floating combat text and memory/widget destruction?](https://forums.unrealengine.com/questions/877146/floating-combat-text-and-memorywidget-destruction.html)**
>
> Hello, I’ve made a system for floating combat text, but I am a little worried that this will cause issues with memory. As it stands, every time the player or an enemy receives damage a simple widget displaying the damage value (as well as effects...

---

<div class="post-metadata">

**Author:** ![Nebula\_Games\_Inc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Nebula\_Games\_Inc](https://forums.unrealengine.com/u/Nebula_Games_Inc)\
**Post date:** [May 30, 2019, 4:54pm UTC](https://forums.unrealengine.com/t/destroy-widget-garbage-collection/449817/4 "2019-05-30T16:54:41Z")

</div>

Haha, yea, I posted the link above 🙂

---

<div class="post-metadata">

**Author:** ![Claudiu.Schwartz](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Claudiu.Schwartz](https://forums.unrealengine.com/u/Claudiu.Schwartz)\
**Post date:** [May 30, 2019, 8:34pm UTC](https://forums.unrealengine.com/t/destroy-widget-garbage-collection/449817/5 "2019-05-30T20:34:58Z")

</div>

Thank you for your answers, yea, I’ve read the discussions on manually calling garbage collection (and it’s downsides). I just thought things have changed meanwhile and the - what I consider to be - issue has been “solved”.

Thx for the hlp tho 🙂
