Skip to content

Commit 1d3b888

Browse files
committed
Create Dump.md
1 parent 2aff67a commit 1d3b888

File tree

1 file changed

+52
-0
lines changed

1 file changed

+52
-0
lines changed

website/docs/guide/Dump.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
sidebar_position: 4
3+
---
4+
5+
### Dump 转储文件
6+
7+
在自动升级的过程中如果更新失败,或程序更新完成之后运行崩溃都可以使用ProcDump工具辅助导出dump文件。ProcDump 是一个命令行实用工具,其主要用途是监视应用程序的 CPU 峰值,并在出现峰值期间生成故障转储,管理员或开发人员可以使用这些转储来确定出现峰值的原因。 ProcDump 还支持挂起窗口监视(使用与 Windows 和任务管理器使用的窗口挂起相同的定义)、未处理的异常监视,并且可以根据系统性能计数器的值生成转储。 它还可用作可嵌入到其他脚本中的常规进程转储实用工具。
8+
9+
##### (1)Windows平台
10+
11+
C#实现调用:
12+
13+
```c#
14+
using System;
15+
using System.Diagnostics;
16+
17+
public class Program
18+
{
19+
public static void Main()
20+
{
21+
var procDumpPath = @"C:\Path\To\procdump.exe";
22+
var processId = 1234; // 您要转储的进程的ID
23+
var dumpFilePath = @"C:\Path\To\dumpfile.dmp";
24+
25+
var startInfo = new ProcessStartInfo
26+
{
27+
FileName = procDumpPath,
28+
Arguments = $"-ma {processId} {dumpFilePath}",
29+
UseShellExecute = false,
30+
RedirectStandardOutput = true,
31+
RedirectStandardError = true,
32+
CreateNoWindow = true
33+
};
34+
35+
var process = new Process { StartInfo = startInfo };
36+
process.OutputDataReceived += (sender, e) => Console.WriteLine(e.Data);
37+
process.ErrorDataReceived += (sender, e) => Console.Error.WriteLine(e.Data);
38+
39+
process.Start();
40+
process.BeginOutputReadLine();
41+
process.BeginErrorReadLine();
42+
43+
process.WaitForExit();
44+
}
45+
}
46+
```
47+
48+
49+
50+
参考资料:
51+
52+
- https://learn.microsoft.com/zh-cn/sysinternals/downloads/procdump

0 commit comments

Comments
 (0)