memory leak with files

BlitzMax Forums/BlitzMax Programming/memory leak with files

Robert Cummings(Posted 2005) [#1]
Graphics 640,480,0

While Not KeyHit(KEY_ESCAPE)

	If KeyHit(KEY_SPACE)
		file = ReadFile("test.map")
		CloseFile file
	EndIf

	Cls
	DrawText MemAlloced(),0,0
	FlushMem
	Flip
	
Wend
End


Memory consumption increases with each read and closed file. test.map can be any file of your choice.


MrCredo(Posted 2005) [#2]
same problem here
WinXPSp2


Yan(Posted 2005) [#3]
Graphics 640,480,0

While Not KeyHit(KEY_ESCAPE)

	If KeyHit(KEY_SPACE)
		file = ReadFile("test.map")
		CloseFile file
		Release file
	EndIf

	Cls
	DrawText MemAlloced(),0,0
	FlushMem
	Flip
	
Wend
End
or

Graphics 640,480,0

While Not KeyHit(KEY_ESCAPE)

	If KeyHit(KEY_SPACE)
		file:TStream = ReadFile("test.map")
		CloseFile file
	EndIf

	Cls
	DrawText MemAlloced(),0,0
	FlushMem
	Flip
	
Wend
End



skidracer(Posted 2005) [#4]
or file:TFile = ReadFile("test.map")


Michael Reitzenstein(Posted 2005) [#5]
Shouldn't CloseFile do an implicit Release?

Edit: Oh, sorry, no it shouldn't.


Robert Cummings(Posted 2005) [#6]
Thanks for clearing up that silly little bug everyone! My mistake.


MrCredo(Posted 2005) [#7]
*headshot*