# 创建和打开快照

> For the complete documentation index, see [llms.txt](https://www.jetbrains.com.cn/help/idea/llms.txt).

> **TL;DR**
> 性能分析器主页：  `查看 | 工具窗口 | Profiler`

本主题解释了创建快照的步骤。 收集数据后，您可以立即分析快照、保存以供日后使用，或发送给其他人。

## 前提

您可以使用默认设置来分析大多数应用程序。 除非您使用 Linux 或希望使用自定义 profiler，否则无需 [configuration](custom-profiler-configurations.html)：所有功能开箱即用。

> **Note:**
> 对于 Linux 和定制，请参阅 [自定义 profiler 配置](custom-profiler-configurations.html)。

IntelliJ Profiler 支持以下 [运行配置](run-debug-configuration.html)：

|  |  本地进程  |  [运行目标](run-targets.html)  |
| --- | --- | --- |
|  [应用程序](run-debug-configuration.html#createExplicitly)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |
|  [Spring Boot](run-debug-configuration-spring-boot.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |
|  [Micronaut](micronaut.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |
|  [Kotlin](run-debug-configuration-kotlin.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |
|  [Ktor](ktor.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |
|  [JUnit 和 Arquillian JUnit](run-debug-configuration-junit.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |
|  [TestNG 和 Arquillian TestNG](run-debug-configuration-testng.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |
|  [Maven](profile-maven-goals.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能不受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/cross_retina.png)  |
|  [Gradle](create-run-debug-configuration-gradle-tasks.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能不受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/cross_retina.png)  |
|  [Tomcat 服务器本地](run-debug-configuration-tomcat-server.html)  |  ![功能受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/check_retina_bold_2.png)  |  ![功能不受支持](https://resources.jetbrains.com.cn/help/img/idea/2026.3/cross_retina.png)  |

这些配置为您处理先决条件。 如果所需的配置不在列表中，欢迎在 [我们的问题跟踪器](https://youtrack.jetbrains.com/issues/IDEA?q=Subsystem:%20%7BJava.%20Profiler.%20CPU%\7D)中创建或投票请求。

为了附加到 IntelliJ IDEA 外部启动的进程，请确保启用 [JMX](https://www.oracle.com/java/technologies/javase/docs-jmx-jsp.html)。

## 开始分析会话

您可以使用 profiler 启动应用程序，或附加到已在运行的应用程序。

Procedure: 使用分析器启动应用程序

* 按 `Alt+Shift+F10` (Windows), `⌃ ⌥ R` (macOS), `⌥ ⇧ F10` (IntelliJ IDEA Classic (macOS)), `⌃ ⌥ R` (macOS System Shortcuts), `Alt+Shift+F10` (XWin), `Alt+Shift+F10` (GNOME), `Alt+Shift+F10` (KDE), `Alt+Shift+F10` (Emacs), `Alt+Shift+F10` (Sublime Text), `⌃ ⌥ R` (Sublime Text (macOS)), `Ctrl+Alt+Shift+R` (Visual Studio), `⌘ ⌥ ⇧ R` (Visual Studio (macOS)), `Alt+Shift+F10` (NetBeans), `Alt+Shift+F10` (Eclipse), `⌃ ⌥ R` (Eclipse (macOS))，选择您想要分析的运行/调试配置，然后从菜单中选择   使用 IntelliJ Profiler 进行分析  。

![从运行弹出窗口中选择 Profile](https://resources.jetbrains.com.cn/help/img/idea/2026.3/profile-rc.png)

* 或者，点击边距中的   运行  图标。 从菜单中选择   使用 IntelliJ Profiler 进行分析  。

![点击 Run 槽图标后会出现带有 Profile 选项的菜单](https://resources.jetbrains.com.cn/help/img/idea/2026.3/intellij-profiler-gutter.png)

您还可以分析以调试模式启动的应用程序。 要做到这一点，首先启动调试会话，然后 [将 profiler 附加](#attach) 到正在运行的进程。

Procedure: 附加到已启动的运行配置

* 如果您想通过 IntelliJ Profiler 运行配置启动的进程进行分析，请转到   运行   或   服务   工具窗口中的相应选项卡，然后点击  `分析进程 | 添加 Profiler | IntelliJ Profiler` 。

![attach-from-run-tw.png](https://resources.jetbrains.com.cn/help/img/idea/2026.3/attach-from-run-tw.png)

Procedure: 附加到任意进程

您还可以将 profiler 附加到系统上运行的任意 Java/Kotlin 进程。

1. 流程已经启动后，打开   分析器  工具窗口。

2. 在   首页  选项卡中，找到您要分析的进程。 右键点击，然后选择   附加 IntelliJ Profiler

![右键点击进程时会出现一个菜单，允许您将分析器附加到该进程](https://resources.jetbrains.com.cn/help/img/idea/2026.3/attach-from-home-page.png)

分析器将在进程终止时自动分离并保存快照。 否则，如果您想让进程继续运行并仅分离 profiler，您可以手动进行操作。

Procedure: 停止分析会话

* 在   分析器  工具窗口中，导航到为您正在分析的进程打开的选项卡，然后点击   停止分析并显示结果  。

![在 Profiler 工具窗口中停止分析并显示结果按钮](https://resources.jetbrains.com.cn/help/img/idea/2026.3/stop-profiling.png)

## 打开快照

快照将立即打开。 此外，如果您想稍后访问它，您可以在   首页  标签的   分析器  工具窗口中找到它。 在此标签中，您可以查看最近的快照或打开存储在硬盘其他位置的快照。

![分析器工具窗口中的最近快照面板](https://resources.jetbrains.com.cn/help/img/idea/2026.3/recent-snapshots.png)

默认情况下，快照存储在用户主目录中。 如果您希望使用其他位置，您可以更改该位置。

Procedure: 更改快照位置

1. 打开   分析器   工具窗口 (  `查看 | 工具窗口 | Profiler` )。

2. 在   首页   选项卡上，点击   更多  ，然后选择   更改快照文件夹…  。

![More 菜单中的 Change Snapshot Folder 项](https://resources.jetbrains.com.cn/help/img/idea/2026.3/change-snapshot-folder.png)

## 本机分析

默认情况下， IntelliJ Profiler 仅收集 Java 堆栈跟踪，但它也可以收集本地调用数据。 这在您需要查看 JNI 调用、垃圾收集、JIT 编译器操作等情况时很有用。

Procedure: 在快照中包含原生示例

* 按 `Ctrl+Alt+S` (Windows), `⌘ Comma` (macOS), `⌘ Comma` (IntelliJ IDEA Classic (macOS)), `⌘ Comma` (macOS System Shortcuts), `Ctrl+Alt+S` (XWin), `Ctrl+Alt+S` (GNOME), `Ctrl+Alt+S` (KDE), `Ctrl+Alt+S` (Emacs), `Ctrl+Alt+S` (Sublime Text), `⌘ Comma` (Sublime Text (macOS)), `Ctrl+Alt+S` (Visual Studio), `⌘ Comma` (Visual Studio (macOS)), `Ctrl+Alt+S` (NetBeans), `Ctrl+Alt+S` (Eclipse), `⌘ Comma` (Eclipse (macOS)) 打开设置，然后选择  `构建、执行、部署 | Java Profiler` 。 选中   收集本机调用   复选框。

