【问题标题】:dotMemory command line scheduled snapshotsdotMemory 命令行计划快照
【发布时间】:2021-05-11 13:23:08
【问题描述】:

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

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

我找到了两种方法:

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

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

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

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

【问题讨论】:

    标签: powershell memory jetbrains-ide profiler dotmemory


    【解决方案1】:

    如果您在分析下启动应用而不是附加到已运行的进程,停止分析会话将终止分析下的应用。您可以通过将##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.
    

    附: 关于命令行的一些注释。使用此命令行 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

    【讨论】:

    • 感谢 Ed.ward!关于您所说的:“例如,某些脚本可以在一段时间后做到这一点”。这是我正在寻找的东西,如果你知道这样做的方法,请与我分享。这是确切的问题,如何将##dotMemory["disconnect"] 消息发送到dotMemory 运行进程stdin 而无需手动进行?我发送的命令行只是我如何做的一个例子。
    • 您可以在 C# 程序中使用 Process.Start 来启动 dotMemory.exe。或者使用本文中描述的 powershell 脚本。 stackoverflow.com/a/16100200/779822
    • 也可以使用磁盘上的文件作为输入。使用 use --service-input=path\to\your.file 命令,然后使用您喜欢的任何方法将命令写入此文件。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-10-23
    • 2013-11-07
    • 1970-01-01
    • 2019-11-23
    相关资源
    最近更新 更多