We have a setup similar to Lyra example project where we use the PrimaryGameLayout and 4 CommonUI Stacks to push our UI screens and hud as ActivatableWidgets
We noticed however that any texture and sprite referenced by those widgets is never released from memory, even when the screen/widget is popped out of the stack and we confirm that the ref counter to the texture is 0.
We suspect it might be something related to widget pooling but we would like help figuring out what is the bug/issue.
For now the only workaround we found (that however makes the UI development not sustainable) is to
Load/Reference all textures from soft references when the widget is activated and manually set the brush back to empty when the widget is deactivated.
Do you have any insight on why CommonUI Activatable widgets together with Stacks could cause such an issue? Is there a way to force the pool to be cleared when changing experience for example? [Image Removed]
Steps to Reproduce
We have a setup similar to Lyra example project where we use the PrimaryGameLayout and 4 CommonUI Stacks to push our UI screens and hud as ActivatableWidgets
Add and remove Screens/Widgets to one of the stacks multiple times and load into different levels/maps.
Observer that the allocated memory for textures keeps growing and textures referened from closed screens (deactivated and removed from the stack) are never released
The ActivatableWidgetStacks used in the PrimaryGameLayout setup do pool widgets by default, so it sounds like that could be the culprit here. How are you removing the widgets from those stacks? If you’re using Pop Content from Layer then the widget should be removed from the pool, a breakpoint in UCommonActivatableWidgetContainerBase::ReleaseWidget could confirm this. We’d expect to see that call to GeneratedWidgetsPool.Release, so you could inspect the pool there and see if anything unexpected is in there.
Another good thing to try here would be “obj list name={texturename}” in the console, which should give you the reference chain. That should point to whatever object is keeping that texture from being garbage collected.
@Cody.Albert Thanks for the reply.
So if I understand correctly, calling Deactivate on a CommonActivatableWidget is not enough to have it actually Pop from the stack (CommonActivatableContainer) and released from the cache, but you actually have to call PopContentFromLayer to have it released?
I took the example setup from the Lyra project and then based on the documentation assumed that calling deactivate would automatically pop it from the top of the stack (because functionally this is how it behaves and deactivating a screen actually take you back to the previously pushed screen).
I will investigate and see if calling Pop reduce the memory pressure while potentially adding some loading time everytime I visit the screen again