BBC BASIC for Windows
Programming >> Operating System >> AUTO cleanup
http://bb4w.conforums.com/index.cgi?board=os&action=display&num=1244190355

AUTO cleanup
Post by Michael Hutton on Jun 5th, 2009, 08:25am

I shouldn't really post this as I haven't done any reading on this subject at all but I was wondering if anyone had any ideas or had got anywhere towards creating a automatic cleanup routine, or indeed if this could be done at all?

I think it would be a very useful library routine that could detect handles to dialog boxes, GDI objects etc (can this be done?), or libraries or any other such objects which the user has created and automatically delete them.

This would be a great asset to the language, and the user wouldn't have to create a custom cleanup routine everytime a windows object is created.

Just a thought.

Michael
Re: AUTO cleanup
Post by admin on Jun 5th, 2009, 09:01am

Quote:
This would be a great asset to the language, and the user wouldn't have to create a custom cleanup routine everytime a windows object is created.

Bear in mind that Windows is pretty good at cleaning up after itself when a process is terminated. So, although it's good practice to do so, you often don't need to worry too much about deleting objects on exit once your program is 'compiled'.

The issue arises when you are developing the program in the IDE, in which case no 'automatic cleanup' takes place until you actually quit BB4W completely. However, even then you may get away with it if you're not running the program very many times (this applies mainly to simple objects; it may be more important to clean up COM objects etc.).

A more serious issue is avoiding resource leaks while your program is running. No 'automatic' cleanup will ever help you there.

Quote:
indeed if this could be done at all?

This is plainly not a BB4W-specific issue, but affects all languages. Have you seen an 'automatic cleanup' routine in any programs written in a different language (e.g. C)? If not, you should perhaps ask yourself if that is significant!

Richard.