Flushmem not freeing allocated memory?

BlitzMax Forums/BlitzMax Beginners Area/Flushmem not freeing allocated memory?

Grisu(Posted 2005) [#1]
Hi!

Simple as that:

1. I load an image
2. Set it = NULL
3. Flushmem()
4. Goto 1.

This creates a memory leak... why?


tonyg(Posted 2005) [#2]
Grisu,
This works OK on 1.06
Incbin "gfx/back.png" 
Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
  Cls
  image:TImage = LoadImage("incbin::gfx/back.png")
  DrawImage image,0,0
  DrawText MemAlloced(),100,100
  Flip
  image = Null
  FlushMem()
Wend

Are you loading the image into an integer handle (image=loadimage rather than image:TImage=loadimage)?
If so you have to release image rather than null.
Incbin "gfx/back.png" 
Graphics 640,480
While Not KeyHit(KEY_ESCAPE)
  Cls
  image = LoadImage("incbin::gfx/back.png")
  DrawImage image,0,0
  DrawText MemAlloced(),100,100
  Flip
  Release image
  FlushMem()
Wend



Grisu(Posted 2005) [#3]
Yes, I loaded the image into an integer handle.
Didn't know the ":TImage" type?

Thanx!