Why is in this loop memory leak?
#10
Code: (Select All)
img& = _ScreenImage
Dim P(320, 240) As Long
Dim C As _Unsigned Long, W As Long
V& = _NewImage(320, 240, 32)
_PutImage , img&, V&
For Y = 0 To 239
    For X = 0 To 319
        _Source V&
        C = Point(X, Y)
        W& = _NewImage(1, 1, 32)
        _Dest W&
        _Source W&
        PSet (0, 0), C
        P(X, Y) = _CopyImage(W&, 33)
        _Dest 0
        _FreeImage W&
Next X, Y
'creating hardware pixels done...

'Beep


Screen _NewImage(320, 240, 32)
_FullScreen

'Do
'Loop
'if is my program stop here, in neverending loop, memory leak not occur.


Do
    For yy = 0 To 239
        For xx = 0 To 319
            X3D = ((xx - 160) / 160) * 3
            Y3D = ((yy - 120) / 120) * 3
            _PutImage (xx, yy), P(xx, yy)
        Next
    Next
    _Display
    _Limit 20
Loop
'RUN THIS UNCOMPLETE PROGRAM
'look at the task manager, how our free memory is disappearing beautifully, despite the fact that this loop has no other task than to use the memory that was previously allocated.


As you can see here, the limit is slowing things down to the point where we're freeing the memory at the same rate that we're using it, keeping us at a steady memory usage.  Wink
Reply


Messages In This Thread
Why is in this loop memory leak? - by Petr - 02-27-2023, 02:55 PM
RE: Why is in this loop memory leak? - by Petr - 02-27-2023, 03:43 PM
RE: Why is in this loop memory leak? - by Petr - 02-27-2023, 04:52 PM
RE: Why is in this loop memory leak? - by Petr - 02-27-2023, 04:56 PM
RE: Why is in this loop memory leak? - by Petr - 02-27-2023, 05:14 PM
RE: Why is in this loop memory leak? - by SMcNeill - 02-27-2023, 05:17 PM
RE: Why is in this loop memory leak? - by Petr - 02-27-2023, 05:29 PM
RE: Why is in this loop memory leak? - by Petr - 02-27-2023, 05:38 PM
RE: Why is in this loop memory leak? - by Petr - 02-27-2023, 05:45 PM



Users browsing this thread: 4 Guest(s)