我正在针对IoT Windows窗体应用程序运行dotMemory命令行,该应用程序需要在自定义设备上进行数小时的测试。
我的目的是在应用程序在设备上运行时,按时间获取内存快照。例如,如果测试设计为运行24小时,我希望每小时获得10秒的内存快照。
我找到了两种方法:
- 运行dotMemory.exe,通过使用
schtasks
调度每次执行,在时间基础上获得独立快照 - 使用
attach
和trigger
参数运行dotMemory,并在单个文件中获取所有快照
我已经准备好了第一个场景,但很容易看到,第二个场景在收集数据后可以更好地进行进一步分析。
我可以使用如下命令启动它:
C:dotMemorydotMemory.exe attach $processId --trigger-on-activation --trigger-timer=10s --trigger-max-snapshots=24 --trigger-delay=3600s --save-to-dir=c:dotMemorySnapshots
我的问题来了:
- 在没有任何人为干预的情况下,如何使命令/进程在达到最大快照值后停止
参考:https://www.jetbrains.com/help/dotmemory/Working_with_dotMemory_Command-Line_Profiler.html
如果您在评测中启动应用程序,而不是附加到已经运行的进程,那么停止评测会话将终止评测中的应用程序。您可以通过将##dotMemory["disconnect"]
命令传递到dotMemory控制台stdin来停止分析会话。(例如,一些脚本可以在一段时间后完成此操作(。
详见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.
p.S。关于命令行的一些注意事项。通过此命令行,dotMemory将每10秒获得一个快照,但将在一小时后开始执行。不存在";10秒存储器快照";内存快照是内存中对象图的瞬时快照。您任务的正确命令行将是C:dotMemorydotMemory.exe attach $processId --trigger-on-activation --trigger-timer=1h --trigger-max-snapshots=24 --save-to-dir=c:dotMemorySnapshots