PPRuNe Forums - View Single Post - Best way to end processes?
View Single Post
Old 7th February 2001 | 11:08
  #3 (permalink)  
SevenFiftySeven
Guest
 
Posts: n/a
Post

Putting my programmers head on for a moment.....

In theory, they are be right - some of the time, but it depends how the code behind the program was written.

(Trying not to get too technical or boring here - apologise if I do!)

Basically, everything that happens in a computer program is 'event' driven - that is, you click a button and an event calls a piece of code to do something.

So, as a programmer, I add a button to my program called 'close' and put some code in the button_click event that basically tells the program to end. All well and good at the moment - So far it doesn't matter if the user clicks the close button or the 'X' button at the top.

However, before I tell the program to close, I may do some other stuff, such as clearing temporary files, free up resources or otherwise within my buttons event. Therefore if the user clicks the 'X' button and not the 'clsoe' button, then this custom code is not called - and thus, we don't neccessarily shut down the same way. This can cause bits of the program to still be loaded in memory and over time, could cause the computer to slow down - although as Matelot has said, when you reboot the computer, then this memory is cleared up.

This can lead to what we call in the trade 'Memory leak' and is the bugbear of most programmers.

Basically, any decent programmer will spend time ensuring that this doesn't happen, but occasionally, things are missed or the programmer may not bother to check in as much detail as he/she should.

This wouldn't happen in most commercial programs though, but hey, we're only human too and we do sometimes make mistakes.
This is especially true when coding at 4 o'clock in the morning in a rush to get some software released!

I think one of the early versions of Microsoft Office would lock the file you were using and only unlock it if you hit the 'close' button. Thus if you closed the application by using the 'X' button, even when you restarted the computer, Office thought the file was still locked and wouldn't work properly until you manually unlocked the file.

As I said though, most of the time you won't come across this and I wouldn't concern yourself about this situation if I were you.

Hope it helps and wasn't too boring for all you non programmers!