Memory leak in FreeImage on mac?

BlitzMax Forums/Brucey's Modules/Memory leak in FreeImage on mac?

ima747(Posted 2009) [#1]
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.


Brucey(Posted 2009) [#2]
Are you using the latest release version of the module or the one from SVN?

I've just run your test over 90,000 iterations using the latest SVN version, and I am not getting any leaks - I am running it through the Apple Instruments development suite, and at the most it shows about 88 live objects, which drops back down to 55 or so from time to time.


ima747(Posted 2009) [#3]
Latest release off your side through the link in your sig I believe. Where can I grab a newer version?


ima747(Posted 2009) [#4]
Sorry for the false alarm, no leak I can find in FreeImage. 1.06 looks great by the way, any reason I should stick to 1.05 or is it close enough to be acceptable?


ima747(Posted 2009) [#5]
Correction on my correction. 1.06 doesn't seem to load transparent png's correctly, I get either black or totally transparent.


Brucey(Posted 2009) [#6]
1.06 is a work in progress - being a major update to the latest version of FreeImage.
As you've found, there are still a few outstanding issues with it, which I hope to sort out soon.


Brucey(Posted 2009) [#7]
... interesting. They've changed the RGBA order on Mac x86... or something.

Updated in SVN.


ima747(Posted 2009) [#8]
excellent I'll give it another try asap