共用方式為


How to: Attach and detach performance tools to running processes

Applies to: yesVisual Studio noVisual Studio for Mac

Note

This article applies to Visual Studio 2017. If you're looking for the latest Visual Studio documentation, see Visual Studio documentation. We recommend upgrading to the latest version of Visual Studio. Download it here

The profiler can be used to attach to or detach from a running process to make sampling and gathering performance data easier. You can use this method to profile a process when you want to avoid gathering data about application load time, or to monitor the performance of a process after it reaches a specific state.

Note

The following steps apply to attaching and detaching processes from within the Visual Studio integrated development environmnent (IDE). For information about how to use command line tools, see Profile from the command-line. For information about how to profile services, see Profile services.

The processes that are available to profile depend on the User Access Permissions that are set by an administrator of the computer. A User account may, for example, have permission for any of the following:

  • Advanced profiling features, when the administrator has set the driver and service to start.

  • Sample profiling only (domain users).

  • Deny access to profiling to everybody.

    For more information, see Profiling and Windows Vista security and the ADMIN options in VSPerfCmd.

To attach to a running process

  1. On the Debug menu, point to Profiler, then Performance Explorer, and then click Attach.

    The Attach Profiler to Process dialog box appears.

  2. Click the name of the process that you want to attach to.

  3. Click Attach.

To detach from a running process

  1. n the Debug menu, point to Profiler, then Performance Explorer, and then click Detach.

    The Attach Profiler to Process dialog box appears.

  2. Click the image name from which you want to detach.

  3. Click Detach.

See also