Verse GarbageCollector issues

Please select what you are reporting on:

Verse

What Type of Bug are you experiencing?

Verse

Summary

The Verse GarbageCollector does not work properly.

Steps to Reproduce

hello_world_device := class(creative_device):
    OnBegin<override>()<suspends>:void=
        Multiplier:=100000
        var I: int = 0
        loop:
            if (I>1000):
                break
            Print("Reached {I*Multiplier}")

            var J: int = 0
            loop:
                if (J>=Multiplier):
                    break
                One:=test_class{}
                set J+=1
            Sleep(0.0)
            set I += 1

Expected Result

Verse should see that those objects arenā€™t referenced anywhere. It should clear those up.

Observed Result

LogVerse: Error: VerseRuntimeErrors: Ran out of memory for allocating UObjects while attempting to construct a Verse object: test_class!

Platform(s)

All

The status of FORT-733785 incident has been moved from ā€˜Needs Triageā€™ to ā€˜Backloggedā€™.

2 Likes

Based on my new understanding from the defer page:

and looking up RAII:

I can conclude that you would have to exit the scope of your OnBegin in order to lose the reference to I, which would then garbage collect I.

For example, if you tried to access J from below set I += 1, the lack of reference is indicative that the value will be garbage collected.

This bug report isnā€™t related to var I: int or var J: int at all. The issue is that the test_class{} instances remain in memory even tho i leave their scope several times.

1 Like

Oh wow, sorry I canā€™t read.

I think you need to have a sleep in this loop:
image

Assuming you likely know this at this point but Iā€™ll try running this later and see what I can find on it.

I think Iā€™ll go with a bit more straightforward test cases though, I got lost a few times on this one already XD

I donā€™t think that would help. Looks like a bug but maybe a workaround would be to put the loop in separate method.

1 Like