Wednesday, May 25, 2011

Software : Tutorial: Find out why a program keeps locking up

Software : Tutorial: Find out why a program keeps locking up


Tutorial: Find out why a program keeps locking up

Posted: 25 May 2011 04:45 AM PDT

Application crashes can be annoying, and Windows crashes are often disastrous, but at least both are usually accompanied by some form of error message.

And entering the relevant text at your favourite search engine will often provide useful clues on the cause of your problems, and how to ensure they don't happen again.

When a program just locks up, though, it's a different story. You'll wait, and wait, and wait, hoping that maybe the application will come back to life. Then finally you lose patience, and close it down from Task Manager, perhaps losing valuable data.

But this time there's no error message, no alert, no clue as to what the problem might be - unless you get a little help from some handy troubleshooting tools.

1. Resource Monitor

If you're running Windows 7, then a little-known diagnostic feature could help you not only figure out why your program has locked up, but also get it working again. And it's surprisingly easy to use.

The next time a program appears to hang, click Start, type RESMON and click the RESMON.EXE link to launch the Windows 7 Resource Monitor.

Click the CPU tab and scroll down the list of running processes until you find the one that's frozen. If it really has locked up, then this should be highlighted in red. (If you don't see anything, then maybe it's just busy; switch back to the program and give it another few minutes.)

Once you've found the highlighted process, right-click it and select Analyze Wait Chain. If Resource Monitor tells you that the process is "running normally" then it won't be able to do anything to fix the hang. But if it's showing you that your process is waiting for another, then it'll provide more details - and that means there's still hope.

Resource monitor

UNLOCKED: Resource Monitor often shows you why your program has locked up - and can even get it running again

Cloudmark's DesktopOne, for instance, is an excellent spam filter, but in its early beta days was prone to locking up other programs. And when we used Resource Monitor, we'd often find that a program was waiting for the DesktopOne executable, CDSWIN.EXE.

So we would save any unsaved work in other applications (just for safety), check the CDSWIN.EXE checkbox in the Analyze Wait dialog, click End Process, and that was usually it - our frozen program would come back to life, and we could continue using it as before.

If you find something similarly non-critical that appears to be blocking an application of yours, then you can do much the same thing: close down the offending process and your app may also start working again.

However, you need to be cautious. If you forcibly close a Windows component or other system-critical application then you might crash your PC. Even if it's nothing important, there are no guarantees that your locked-up program will return to normal (it may stay frozen, it might even crash).

And if a process is waiting for another instance of itself (FIREFOX.EXE waiting for FIREFOX.EXE, say), then you probably won't be able to use this trick at all: closing one may also shut down the other, so you'll lose both.

If Resource Monitor doesn't work for you, then, you'll want to try something else. And fortunately there are a couple of worthwhile alternatives.

2. WhatIsHang

WhatIsHang is a tiny portable tool that can provide important clues as to why a program might be locking up.

It's more complicated than Resource Monitor, but then it also provides more information, and the tool works on any version of Windows from 2000 upwards (although it only detects hangs in 32-bit applications).

When you notice that an application has locked up, run WhatIsHang (right-click it and select Run as Administrator in Windows Vista or 7) and it should highlight the frozen window for you. Select this, click File > Get Hang Information and the program will display information that may help to explain the issue.

WhatIsHang

CLUED IN: WhatIsHang can sometimes offer clues as to why a program has locked up

If you're lucky this may include some very specific advice on possible causes of your problems. WhatIsHang might point out that the locked-up process appeared to have been working with a network file recently, for instance; if you're having network problems, or the file can't be accessed for some reason, then that may explain why your program has frozen.

WhatIsHang will also display your program's stack data, though, essentially just a list of information that the program has been working with recently.

Take a look at this: are there any file names you recognise? Could the program be trying to access some file or folder that's not available right now, like an external drive that hasn't been connected? Just browse the data on offer, and look for any clues that might give you an idea of what your troubled program is trying to do.

While WhatIsHang can help occasionally, often the problem is more deeply buried. But that's okay, there's a far more powerful option available.

3. Process Hacker

Process Hacker is the ultimate souped-up Task Manager, a comprehensive tool that can tell you everything you need to know about your running processes. And, fortunately for our purposes, it's just as useful when it comes to figuring out why a program appears to have locked up.

To find out more about your broken application, first double-click its name in the Process Hacker list, and click the Handles tab. This will show you all the files, Registry keys and other Windows objects that the program has open, which again may offer you some clues about what it's trying to do.

Process hacker

IN DETAIL: Process Hacker is an incredibly powerful tool for finding out more about what's happening on your PC

Next, click the Modules tab, which will reveal all the DLLs and other support files that your application is using. This generally won't mean much, even to experienced Windows users, but just browse the Description column anyway for anything that might be relevant.

For example, if a program started locking up a week ago, and you see it's loading something described as a "Microsoft Office 2010 Component", and you reinstalled Office a week ago, then that may well point you in the right direction. Enter the particular DLL file name at Google to see what comes up.

And finally, click the Thread tab to see a list of process threads, the Windows objects that are actually responsible for running code. Right-click each of these, select Analyze > Wait, and Process Hacker will tell you what, if anything, the thread is actually waiting for.

This might be a file, a user message (a mouse click or keypress), or one of many Windows objects: the Process Hacker author explains more about how to interpret the results, and use them to resolve any problems, on his own site (this is aimed at developers and other expert users, but his comments also contain much more accessible information).

If this still doesn't help, then we'd fall back to more generic troubleshooting techniques. Uninstall any unwanted applications, for example; use a tool like UpdateStar to check the rest are up-to-date; update your drivers via Device Doctor, and use CCleaner to free your system of unwanted junk.

It'll take rather longer than using Windows Resource Monitor, but this kind of cleanup can be surprisingly effective, and it just might leave your PC running smoothly again.

No comments:

Post a Comment