Channels ▼

Gaston Hillar

Dr. Dobb's Bloggers

ProcDump v3.02: A Simple Utility that Detects CPU Spikes in Windows

February 15, 2011

ProcDump is a very simple yet powerful command-line utility that monitors an application in Windows and writes a process dump file during a spike. You can use ProcDump to detect applications that block the UI thread and don't respond to window messages for at least five seconds.A few days ago, Mark Russinovich, a well-known member of Windows Sysinternals team, made the new version v3.02 of ProcDump available for download.

This command-line utility runs on most modern Windows versions and includes a very simple hung window monitoring. If you want to create responsive applications, you cannot accept a hung window that doesn't respond to messages because there is synchronous code running in the UI thread. Modern applications must provide a responsive UI and they must pass the hung window monitoring test. ProcDump uses the same definition of a window hang that Windows and its Task Manager use. Thus, if Windows Task Manager adds "Not Responding" to the application's window title and ProcDump is running the hung window monitoring for the application, ProcDump will write a process dump file.

You don't need to run an installer. You can unzip the procdump.exe executable file and run it from the command-line. You just have to specify either the process name or the PID (short for Process ID) as one of the parameters, -h, and the dump file name. ProcDump will start monitoring the specified process and it will write a process dump file if the window hangs. For example, the following line monitors the WindowHung.exe process:

procdump -h WindowHung.exe wh.dmp

Because the application runs a compute-intensive algorithm with a synchronous execution in the UI thread, the windows doesn't respond to window messages for eight seconds. ProcDump shows the hung window detected and writes the dump file:

C:\Sysinternals>procdump -h WindowHung.exe wh.dmp

ProcDump v3.02 - Writes process dump files Copyright (C) 2009-2011 Mark Russinovich Sysinternals - www.sysinternals.com

Process: WindowHung.exe (4904) CPU threshold: n/a Performance counter: n/a Commit threshold: n/a Threshold seconds: n/a Number of dumps: 1 Hung window check: Enabled Exception monitor: Disabled Terminate monitor: Disabled Dump file: C:\Sysinternals\wh.dmp

[20:03.47] Hung window detected.

Writing dump file C:\Sysinternals\wh_110215_200347.dmp … Dump written.

Dump count reached.

Because there were no additional parameters, ProcDump exits when it reaches the default dump count of one. Then, you can open the dump file with Visual Studio to analyze it. You can specify the desired number of dumps to write before exiting with the -n option followed by the number of dumps.

ProcDump is also useful to write dumps of a process when it exceeds certain CPU usage for a specified number of seconds. You just have to specify either the process name or the PID (short for Process ID) as one of the parameters, -c, the CPU threshold, -s, the consecutive seconds, and the dump file name. ProcDump will start monitoring the specified process and it will write a process dump file if the CPU usage is equal or higher than the CPU threshold for the specified consecutive seconds. For example, the following line monitors the ParallelTasks.exe process:

procdump -c 85 -s 8 ParallelTasks.exe CPU_usage.dmp

Because the application runs a compute-intensive algorithm in as many threads as available cores, the CPU usage is more than 85% for many seconds. ProcDump shows the CPU usage threshold reached for eight seconds and writes the dump file:

C:\Sysinternals>procdump -c 85 -s 8 ParallelTasks.exe CPU_usage.dmp

ProcDump v3.02 - Writes process dump files Copyright (C) 2009-2011 Mark Russinovich Sysinternals - www.sysinternals.com

Process: ParallelTasks.exe (6840) CPU threshold: 85% of system Performance counter: n/a Commit threshold: n/a Threshold seconds: 8 Number of dumps: 1 Hung window check: Disabled Exception monitor: Disabled Terminate monitor: Disabled Dump file: C:\Sysinternals\CPU_usage.dmp

[23:46.59] CPU: 87% 1s [23:47.00] CPU: 92% 2s [23:47.01] CPU: 95% 3s [23:47.02] CPU: 96% 4s [23:47.03] CPU: 95% 5s [23:47.04] CPU: 96% 6s [23:47.05] CPU: 98% 7s [23:47.06] CPU: 95% 8s

Process has hit CPU spike threshold. Writing dump file C:\Sysinternals\CPU_usage_110215_234706.dmp ... Dump written.

Dump count reached.

ProcDump has many other options and it can generate dumps based on the value of system performance counters. You can find other examples on the ProcDump page at Windows Sysinternals.

Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.
 


Video