ResizePixmap : Memory Leak

BlitzMax Forums/BlitzMax Programming/ResizePixmap : Memory Leak

ElectricBoogaloo(Posted 2014) [#1]
[code]
Graphics 640,480,0

ImgA=CreatePixmap(1600,1600,PF_RGBA8888)

For n=1 To 1024
ImgB=ResizePixmap(ImgA,1200,1200)
ImgB=Null
GCCollect()

Cls
DrawText n,100,100
DrawText GCMemAlloced(),100,120
Flip
Next
[code]

Although the GCMemAlloced seems.. .. um.. OK'ish...But the Windows Task Manager memory usage goes off the scale.
I'm currently using Windows BMax v1.50
Is this a known issue, a fixable issue, or is there any way around it?


PhotonTom(Posted 2014) [#2]
Declare ImgA and ImgB as type TPixmap and it should clear memory fine:
Graphics 640,480,0
local ImgA:TPixmap
local ImgB:TPixmap

ImgA=CreatePixmap(1600,1600,PF_RGBA8888)

For n=1 To 1024
ImgB=ResizePixmap(ImgA,1200,1200)
ImgB=Null
GCCollect()

Cls
DrawText n,100,100
DrawText GCMemAlloced(),100,120
Flip
Next



Brucey(Posted 2014) [#3]
Putting SuperStrict at the top of your code should make things more clear.


ElectricBoogaloo(Posted 2014) [#4]
Aaah, I see, it's a mis-type sort of thing. Gotcha. Thanks..


(For all future folk with similar issue.. You have to specifically define ImgA:TPixmap and ImgB:TPixmap, and it flies through.)


Yan(Posted 2014) [#5]
Just in case you were wondering why BMax wasn't throwing up errors.

You can use integer handles for objects, but I wouldn't advise it...
Graphics 640,480,0

ImgA=CreatePixmap(1600,1600,PF_RGBA8888)

For n=1 To 1024
ImgB=ResizePixmap(ImgA,1200,1200)
Release ImgB
GCCollect()

Cls
DrawText n,100,100
DrawText GCMemAlloced(),100,120
Flip
Next

More details here.