Problem
You want to capture a heap dump of a Java process on Windows. You launch a command prompt with admin privileges and use "jmap," which is a command-line tool that prints memory-related statistics, but the command returns either an "Access Denied" error message or an "Insufficient Memory" or "Insufficient Privilege to attach" error message.
Examples:


Solution
If Java processes are running in the background, Windows does not allow jmap or jconsole tools to see JVM started as a Windows service. Instead of using jmap to capture a heap dump for a Java process on Windows, use the Microsoft tool PsExec to generate a heap dump.
Example:
