memory leak with files

BlitzMax Forums/BlitzMax Programming/memory leak with files

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.

same problem here
WinXPSp2

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


or file:TFile = ReadFile("test.map")

Shouldn't CloseFile do an implicit Release?

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

Thanks for clearing up that silly little bug everyone! My mistake.

*headshot*