Haven't tested this on PC, but here's a sample that very slowly leaks on my mac
Import BaH.FreeImage
Const textureQuality:Int = 3
Function LoadScaledFreeImage:TFreeImage(spritePath:String, qualitySteps:Float = -1)
Local bahFreeImage:TFreeImage = LoadFreeImage(spritePath)
If(Not bahFreeImage Or Not bahFreeImage.width Or Not bahFreeImage.height)
Print("Failed to load FreeImage with file " + spritePath)
Return Null
End If
If(qualitySteps < 0)
qualitySteps = textureQuality
End If
Local maxTextureRez:Float = 64
For Local onStep:Int = 0 Until qualitySteps
maxTextureRez = maxTextureRez * 2
Next
Return bahFreeImage.MakeThumbnail(maxTextureRez)
End Function
Local count:Int
While Not KeyHit(KEY_Escape)
count = count + 1
Local testImage:TFreeImage = LoadScaledFreeImage("test.jpg")
GCCollect() ' Force a collect to make it easier to watch memory usage
Print count
Wend
watching it's memory and virtual memory usage in Activity Monitor it will slowly climb. I've got some memory leak in the bigger project this is pulled from that after a while causes LoadFreeImage to fail with a memalloc error, not sure if it's just this but this is where I started anyway. Maybe it's just me being stupid or the blitz GC not collecting everything, or maybe a tiny leak in LoadFreeImage, not really sure.
|