Help, my memory is slowly slipping away..

BlitzMax Forums/BlitzMax Beginners Area/Help, my memory is slowly slipping away..

Takuan(Posted 2005) [#1]
errr..sorry..testing again..


Takuan(Posted 2005) [#2]
Ahhh..several hours and curses later i found it:

Method createbuttons(menuename$)
Local file=OpenFile(menuename$+".txt")
While Not Eof(file)
ReadLine(file)
Wend
CloseFile file
End Method

Whats wrong with it?
Put a function in a loop which calls it and enjoy whatching your memory going somewhere..
Flushmem didnt help!


Takuan(Posted 2005) [#3]
Huh? Why Release File works and flushmem not?
Isnt file a local and should be then removed by flushmem?


skidracer(Posted 2005) [#4]
If you use:

Local file:TStream=OpenFile()

The garbage collector will recognize when it exits the method that an object reference has gone out of scope.

Because you are using an integer handle instead, a call to Release is required as the garbage collector can not relate the integer variable going out of scope having any relevance to the reference count on the file object.


FlameDuck(Posted 2005) [#5]
Isnt file a local and should be then removed by flushmem?
Yes, file is local. However as skidracer pointed out it is an integer reference, and not an object reference, thus the garbage collector cannot know when it is "safe" to free the memory.


Takuan(Posted 2005) [#6]
Thank you,
thats why i have to release the loaded bitmap too i think. Good to know, realy started to hate garbage collector, but now everything is just fine:-)