How to destroy a child widget used for vertical box?

Hello,

how to destroy child widget that we dynamically add in vertical box ?

each time the loop do a clear children and add children to the vertical box widget, the cleared childrens stay in memory

how to destroy them from memory?

lets say i want to do a hud heatlh bar,

i will have a “hud health bar” widget, and a “one hearth” widget

each loop i will do a clear children of ‘one hearth’ childs widget from the horizontal bar in “hud health bar” and then i will create x time the “one hearth” widget to add it as children of the horizontal bar

you see the problem? each time the loop proceed the cleared children hearth stay in memory and it will stack with time!!!

so we cant use properly vertical / horizontal box till we cant remove widget from memory

Removing items from vertical boxes should work, I’m having trouble visualizing what it is you’re trying to do, it is likely down to the logic in your loop. Can you give screenshot example of what you want to achieve? (before and after)

removing widget from vertical box with ‘clear childrens’ remove them

but they stay in memory, for example if one of my children had a timer repeating print string ‘hello’ it will still print hello even i removed it from the vertical box. the fact is i only removed them from the vertical box but they still exist somewhere in memory, so each time i will recreate widget to be added in vertical box, the print string ‘hello’ will repeat x time too

we need to be able to destroy a widget and not just remove / clear them

i will try a screenshot to explain

here is a picture to explain the problem

http://i.imgur.com/RKCgpKw.jpg

1 Like

UE4 uses garbage collection, try the console command ‘obj gc’ or wait 60 seconds and see if your memory usage goes down, if not then you do have a memory leak.

Another way to do what you want is to create the 5 hearts and then just add the same ones to the widget each time you after clear it (i.e. hold the hearts in another array that you loop to add the wanted heart).