PDA

View Full Version : Best way to end processes?


fobotcso
6th Feb 2001, 13:36
Does anyone have an opinion on this assertion from the Sunday Times "Doors" supplememnt?

"Do not click on the little 'x' in the top right hand corner of the window to close a program, but instead use the Close or Exit command, usually found under the Files Menu. Clicking on an 'x' can leave bits of a program floating in the computer's memory and will subsequently hamper performance."

My understanding of the way process control blocks work is that they don't care how the process was ended when they do their stuff. This sounds like a bit of "ju-ju" to me. In the same category as "always alternate which shoe you put on first so as to even out the wear". Anybody support this handy tip from The Sunday Times?

matelot
6th Feb 2001, 17:45
I wonder what 'bits' of programme they're talking about, and if it's 'in memory', then that is volatile but the small quantity shouldn't make any difference.

Can't say that I've heard of this before.

Temp files may be written to the HDD and not deleted, but that won't affect other running processes.

??

------------------
Me, sweat? I'm that cool, it's condensation.

SevenFiftySeven
7th Feb 2001, 11:08
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! http://www.pprune.org/ubb/NonCGI/confused.gif

Feline
9th Feb 2001, 02:18
No 757 - most interesting - so what you're saying is that the X does Mr Gates' standardised way, but right clicking on the programme in system tray closes it the way the programmer intended?
That might account for the fact that if I shut down with all my programmes running, the machine never shuts down cleanly. If I close all the programmes before shutdown, no problem. And life's too short to sort it out ...

------------------
Feline
(I Sit, I Watch, I Smile)

fobotcso
9th Feb 2001, 21:46
Thanks 757, and not boring at all. So in essence there may be something in it, but I'm so used to doing it the "bad" way now it will take quite an effort to remember to close using the menu. I infer that it is really only a "nice to do, in case" procedure.

You can be as technical as you like here; that's the nature of the Forum. If people are bored or baffled, they can always take themselves off to Jet Blast! ;)