If I add a widget component and then create a widget and set the widget in the component, then the widget is not garbage collected.
Note: The bottom “add widget component” doesn’t have a widget class set.
If I add a widget component and then create a widget and set the widget in the component, then the widget is not garbage collected.
Note: The bottom “add widget component” doesn’t have a widget class set.
Hello DekanTrue,
This is working as intended, if a widget is being referenced in a UObject it will remain in memory. I hope that this information helps.
Make it a great day
Hi Rudy,
Two things I don’t understand then:
Neither widget will be removed from memory. One test you can run would be to use get all widgets of class and uncheck “Top Level Only”. This a quick way to see how many of a certain widget are still in memory.
I have made that test yes. That is how I noticed the issue.
Upon actor deconconstruction, if I force garbage collection, then the widget in the top example is cleaned. The bottom one is one.
A widget that is created using Create widget will look for the player, then the world, then the game instance. This means that unless all of them are removed (such as when the level is changed) the widget will continue to be referenced. As long as the widget is referenced, it will not be garbage collected.
Why would it be intended to work that way? It just uses memory.
I am noticing a similar issue. I noticed because once the widget is removed the key inputs are still present. So for example I create a widget with input action anykey to make it disappear. When its removed from parent the keys are still being listened to and reacted to. Mind you I am using the old input actions from UE4. In addition Stop listening for all input actions doesnt seem to fix it either.