Open-Turing-Project / OpenTuring

An open source version of the Windows Turing interpreter. Features speed improvements and new features.
http://tristan.hume.ca/openturing
Other
72 stars 41 forks source link

Memory Leak Creating New Pics #48

Open redstarcoder opened 5 years ago

redstarcoder commented 5 years ago

If you create many images, despite using Pic.Free, Turing will ultimately consume all the memory it's allowed to and crash. Code:

View.Set ("graphics:1024;600,offscreenonly")

var spinbox, newbox, angle : int
angle := 0

Draw.FillBox (50, 50, 150, 150, brightcyan)
spinbox := Pic.New (0, 0, 200, 200)
newbox := Pic.Rotate (spinbox, angle, 100, 100)

loop
    cls

    angle := angle + 4
    if angle >= 360 then
        angle := 0
    end if
    Pic.Free (newbox)
    newbox := Pic.Rotate (spinbox, angle, 100, 100)

    Pic.Draw (newbox, 600, 300, picCopy)

    View.Update ()
    delay (10)
end loop