UCommonWidgetCarousel Memory Leak introduced in UE4.27 still in UE5.5

Hi,

I’d agree that the behavior here is a bit bizarre, especially since it’s inconsistent. We only add things to CachedSlotWidgets in RebuildWidget, so anything added dynamically won’t be cached. The caching isn’t strictly necessary since we maintain three slots (previous, current, next) to support the transition, so we can see dynamic widgets being constructed once they are in one of those three slots and destroyed when they leave. Knowing that, we could consider just removing CachedSlotWidgets altogether and letting the widgets construct/destruct naturally.

My only hesitation there is that the caching may be necessary to avoid hitching if the contents of the carousel are very heavy, as a widget would be constructed each time the page transitions. If we do want to keep the current behavior and ensure every child of the carousel stays constructed, we should add widgets to CachedSlotWidgets in UCommonWidgetCarousel::OnSlotAdded in addition to the changes you proposed. I’ll check with some folks to see if we should make that change or if it’s safe to remove the caching outright.

Best,

Cody