gno icon indicating copy to clipboard operation
gno copied to clipboard

GNO2: synchronous garbage collection

Open jaekwon opened this issue 2 years ago • 0 comments

Currently the memory allocator doesn't account for any GC freed objects. That is, objects like large strings or arrays each count against the allocation limit, even for temporary objects that get thrown away after the scope of the function call.

func SomeFunction() {
    x := ""
    for i:=0; i<100; i++ {
        x += "."
    }
}

For example, the above variable x returned is 100 bytes long, but all the prior subsequent strings were also accounted for, from x length 1, 2, 3, .. to length 100. Even though all prior x's become garbage collected, gno's memory management is not yet that smart.

This is a feature request issue to add some kind of synchronous garbage collection mechanism to free up GC'd memory. This could happen between realm function call boundaries, or it could happen with some special system function call. Or maybe this is best solved with function comment directives.

jaekwon avatar Jun 27 '22 23:06 jaekwon