Last active
March 31, 2023 18:09
-
-
Save MattRix/912fd98e498a3e653457986bd65e8f94 to your computer and use it in GitHub Desktop.
A device that shows some kind of memory leak in UEFN/Verse (creating and removing a bunch of UI widgets every frame)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 } | |
<#> | |
After letting this device run for a while, the server will run slowly. | |
Once you remove the device, the server will still keep running slowly | |
even on future publishes, until you end the session and start a new one. | |
It seems something like a memory leak (possibly a GC issue) | |
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) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment