Is Delete Required AND Changing Icon

BlitzMax Forums/BlitzMax Beginners Area/Is Delete Required AND Changing Icon

coffeeaddict(Posted 2011) [#1]
Some newbie questions...

If I declare a custom type using the TYPE command and make an instance of it with NEW do I need to use DELETE to free it from memory or is there internal garbage handling that will take care of it me once the program closes? Essentially what I want to know is, will it cause a memory leak after the program has ended?

Another question- I figured out how to change the title, but how do I go about changing the icon?


Zethrax(Posted 2011) [#2]
BlitzMax has garbage collection, so just removing all references to an object will cause it to eventually be deleted.

All Blitz languages will free the resources they use once the program ends. Third party non-Blitz libs, dlls, etc, may be a different story - so check their documentation to see what the proper procedures are for closing them down.


OscarBraindeaD(Posted 2011) [#3]
@coffeeaddict

In order to change the icon in exe file (in windows) you can use a program called Resource Hacker.

Regards


coffeeaddict(Posted 2011) [#4]
Thanks for the quick answers. :)


ziggy(Posted 2011) [#5]
You can also use blide plus to set the program icon.


ima747(Posted 2011) [#6]
BlitzMax uses a garbage collector. This means that when a resource (object you've created, picture you've loaded, whatever) is no longer reachable (there's no way to get to it any more) it will automatically be released and the memory freed.

When the program itself closes all references are removed by the OS and will be freed. However ass Bill mentioned, not all referenced code elements (libs, dlls, etc.) will be guaranteed to be cleaned up in this fashion. Some may be retained by the OS, or another program etc. This behavior varies by OS and what's you're referencing, so always make sure when you're using something outside of bmax's scope you're polite about cleaning up after yourself. You're unlikely to cause any major problems unless the external reference has it's own problems to begin with, but it makes the world a better place :0)


In addition to tools to patch in an icon, or an IDE that will compile it in for you, you can also build your own icon resource and import it in your app. The disadvantage of this is it's annoying (check around the forums for a guide), however on the upside once you've imported the icon it's there every time you build, and it can be compiled in within the standard IDE or custom IDE's, and if you get into cross compiling you can also build the windows executable on another platform including it's icon. If you go a bit further you can also include other bundle information in the resource such as version info, copywrite, etc.

Also on the subject of other platforms. Each OS has it's own method for handling icons (in the same way they have their own executable formats etc.) so the icon process is different on each.