I’m banging my head against a wall and so frustrated; I’m greatly appreciative for any help. Here’s the situation:
I have a notification system that consists of a parent widget (literally just a vertical box) and children widgets which displays individual information. It works basically identically to Stardew Valley where anytime the character picks something up, a new child widget is added to show what they picked up and it disappears after five seconds or so.
But here’s the annoying part: regardless of how many times I call “Remove from Parent,” the widgets won’t clear from memory, and they aren’t even referenced in any variables. UE4’s garbage collection is supposed to automatically clear widgets from memory but that is clearly not working here.
Sidenote: calling remove from parent also doesn’t stop code from executing within my children widgets, which seems very odd to me.
I’ve greatly simplified the code to the following and still receive the same issue of widgets not leaving memory:
ParentWidget:
ChildWidget:
Things I have tried:
- The parent widget variable is stored as a reference in my game mode bp. This is the only place it is referenced. I’ve tried clearing that variable and removing the parent from memory but all the children still remain in memory.
- I’ve tried calling “Get All Widgets of Class” for the children widgets and, using a for each node, manually removed from parent for all of them. This also does not work.
Things I am trying to avoid: calling “Garbage Collect.” I know I am manually able to call garbage collect (and it does work) but that is such a terrible solution as it causes FPS stutters and is such an unnecessarily intensive operation for what should have a simple solution (particularly doing such an operation for such a fundamental aspect of gameplay that the users will be experiencing a lot would be not great). Yes, I could batch and call Garbage Collect only every so often, but again, this feels like such an inelegant solution. There MUST be another way.
Thank you in advance for your help.