1

我正在针对 IoT Windows Forms 应用程序运行 dotMemory 命令行,该应用程序需要在自定义设备上进行数小时的测试。

我的目的是在应用程序在设备上运行时按时间获取内存快照。例如,如果测试设计为 24 小时运行,我想每小时获取 10 秒的内存快照。

我找到了两种方法:

  1. 运行 dotMemory.exe 并按时间获取独立快照,通过使用schtasks来安排每次执行;
  2. attach使用and参数运行 dotMemorytrigger并获取单个文件中的所有快照。

第一个场景已经为我准备好了,但很容易看出,第二个场景在收集数据后更适合进一步分析。

我可以使用如下命令启动它:

C:\dotMemory\dotMemory.exe attach $processId --trigger-on-activation --trigger-timer=10s --trigger-max-snapshots=24 --trigger-delay=3600s --save-to-dir=c:\dotMemory\Snapshots

我的问题来了:

  • 如何在没有任何人工干预的情况下使命令/进程在达到最大快照值后停止?

参考:https ://www.jetbrains.com/help/dotmemory/Working_with_dotMemory_Command-Line_Profiler.html

4

1 回答 1

0

如果您在分析下启动应用程序而不是附加到已经运行的进程,停止分析会话将终止分析下的应用程序。您可以通过将##dotMemory["disconnect"]命令传递给 dotMemory 控制台标准输入来停止分析会话。(例如,某些脚本可以在一段时间后执行此操作)。

详情见dotmemory help service-messages_

##dotMemory["disconnect"]    Disconnect profiler.
If you started profiling with 'start*' commands, the profiled process will be killed.
If you started profiling with 'attach' command, the profiler will detach from the process.

PS 关于你的命令行的一些注释。使用此命令行 dotMemory 将每 10 秒获取一次快照,但会在一小时后开始执行此操作。没有所谓的“10 秒内存快照”内存快照是内存中对象图的瞬时快照。您的任务的正确命令行将是C:\dotMemory\dotMemory.exe attach $processId --trigger-on-activation --trigger-timer=1h --trigger-max-snapshots=24 --save-to-dir=c:\dotMemory\Snapshots

于 2021-05-11T15:53:14.307 回答