GetSurfaceBrush - FreeBrush

Blitz3D Forums/Blitz3D Programming/GetSurfaceBrush - FreeBrush

WolRon(Posted 2004) [#1]
The Help file says:
Remember, GetSurfaceBrush actually creates a new brush so don't forget to free it afterwards using FreeBrush to prevent memory leaks.

AFAIK, Blitz cleans up after itself, so is this statement saying otherwise? Is this one scenario where Blitz doesn't clean up after itself? Are there others?

What's the consequences if I don't FreeBrush?
Do I (eventually) run out of memory while the program is executing (assuming virtual memory isn't being used)?
After the program ends, does the 'memory leak' affect the OS or other programs (i.e. RAM is 'lost')?


N(Posted 2004) [#2]
If you don't free the brush, it will still use that memory. If you do free the brush, Blitz will stop using that memory and it's available for use by anything else again.

The reason for freeing the brushes is so that when you DO get this new brush, say you get it once every frame, that's a lot of memory that'll get used in a very short time. So, freeing it is a good idea. Same goes for deleting unused objects.