Bug - Permanent server slowdown caused by potential memory leak when creating UI widgets from Verse

If you create a bunch of UI widgets every frame/tick and remove and recreate them the next frame, over and over, gradually your server will run slower and slower. Once the server is running slow, you have to end the session and start a new one in order to get back to normal (which probably just moves you to a new server).

I’ve tried this with creating 100 widgets per tick and the server became almost immediately unresponsive. With 30 widgets per tick, the effect is more gradual, but if you leave it running for 5-10 minutes it becomes VERY apparent.

It’s also possible that the bug is due to the way I am recreating the array every time, perhaps the old contents of the array never get garbage collected?

I’ve included the code below for a device that replicates this bug:

using { /Verse.org/Simulation }
using { /Verse.org/Verse }
using { /Verse.org/Colors }
using { /Verse.org/Random }

using { /UnrealEngine.com/Temporary/UI }

using { /Fortnite.com/Devices }
using { /Fortnite.com/UI }

slow_down_device := class(creative_device):

    Canvas : canvas = canvas{}
    var ColorBlocks : []color_block = array{}

    OnBegin<override>()<suspends>:void =
        if:
            FirstPlayer := GetPlayspace().GetPlayers()[0]
            PlayerUI := GetPlayerUI[FirstPlayer]
        then:
            PlayerUI.AddWidget(Canvas)

        loop:

            for (ColorBlock : ColorBlocks):
                Canvas.RemoveWidget(ColorBlock)

            set ColorBlocks = array{}

            # make tons of new widgets every frame
            for (i := 1..30):
                ColorBlock := color_block:
                    DefaultColor := color {R := GetRandomFloat(0.0,1.0)}
                set ColorBlocks += array{ColorBlock}
                Canvas.AddWidget(canvas_slot {Widget := ColorBlock})
            
            Sleep(0.0)

We’ve been experiencing this bug for a while in our map (8039-8238-9814). We’ve been doing a lot of workarounds to decrease the creation of verse widgets in order to optimize performance since the server starts lagging A LOT after creating too many widgets.

Still a big issue for us :face_exhaling:

@ShockMaps Thank you for your report! Can you please re-post using the “New Issue” option on the Issues and Bug Reporting forums? Posts with this feature are connected directly into our development team so we can quickly get to them!

For more information, such as how to get the reference ID, please check out the article here: Using the Creative and UEFN Bug Reporting Form

I’ve made a thread a not long time ago about Widgets:

Closing this thread in favor of the newer reports.