How to delete media from memory?

BlitzMax Forums/BlitzMax Beginners Area/How to delete media from memory?

MRaven(Posted 2007) [#1]
Hi there,

I'm pretty new to BMax and I miss the "free image" syntax.
How can I delete media files (images, audio) from memory when I don't need them anymore??

Cheers,
Michael


Yan(Posted 2007) [#2]
Short Answer:-

Generally, you don't. Let the garbage collector do it's thing and don't worry about it.


I shall leave it to the throng to supply you with the long answer... ;o)

[edit]
Have a look at this in the meantime. Ignore the references to FlushMem() as collection is done automatically now (or use GCCollect if you must) and MemAlloced() has become GCMemAlloced().

Or open up the IDE and look at...
Help Panel>Tutorials and Articles>BlitzMax Memory Management
[/edit]


GfK(Posted 2007) [#3]
This will work.
image:tImage = Null
sound:tSound = Null


This won't (because another pointer to the same image exists).
image:tImage = Loadimage("MyImage.png")
image2:tImage = image
image = Null

In order to free the image data in the above instance you must also:
image2 = Null