【问题标题】:Using dot memory API to take multiple snapshot on same .dmv file使用点内存 API 在同一个 .dmv 文件上拍摄多个快照
【发布时间】:2017-12-05 11:59:19
【问题描述】:

我正在尝试使用 dot memory api 分析我的特定代码。当我调用 dump() 方法时,我的期望是拍摄快照并将其保存到目录。

我试图在执行我的代码之前和通过调用 dump() 方法执行我的代码之后在这里拍摄两个快照。

是否可以在同一个输出文件中创建两个快照,就像我们选择从独立点内存中创建一样?

感谢您的建议。以下是代码sn-p

SelfAttach.Attach(new SaveSnapshotProfilingConfig
{
   ProfilingControlKind = ProfilingControlKind.Api,
   SaveDir = "D:\\SelfProfiling",
   RedistDir = "D:\\Softwares\\JetBrains.Profiler.SelfSdk.2017.2.2",
   ProfilingType = ProfilingType.Memory,
   ListFile = "D:\\snapshot_list.xml" 
});

while (SelfAttach.State != SelfApiState.Active)
{
     Thread.Sleep(250);  // wait until API starts
}

if (MemoryProfiler.IsActive)
{
   MemoryProfiler.Dump();
   MyMethodTobeProfiled();
   MemoryProfiler.Dump();
}

if (MemoryProfiler.CanDetach)
   MemoryProfiler.Detach();

【问题讨论】:

    标签: c# dotmemory


    【解决方案1】:

    是否可以在同一个输出文件中创建两个快照,就像我们选择从独立点内存中创建一样?

    快照通常是一堆文件。 .dmw 是快照的存档。这就是现在的设计。原因是能够立即开始向远程主机发送快照。这是 R# 要求。

    【讨论】:

    • Mikhail 想说“Self profiling API”旨在嵌入到交付给最终用户的最终产品中,以便最终用户能够在发生内存/性能问题时发送报告。在这种情况下,无需在会话中收集多个快照,但应尽快获取包含问题信息的一个快照并将其发送给开发人员。 “Self profiling API”不是为开发人员自己在开发阶段对应用程序进行分析而设计的。我说得对吗,米哈伊尔?
    • 为什么不呢?我没有看到任何障碍物。如果需要,请使用它。它是开放的 API。
    【解决方案2】:

    我猜你可以使用dotMemory Command Line Profiler 而不是“Self profiling” API 来满足你的需求。

    启动 dotMemory 命令行分析器。 确定分析器已附加到您的应用程序,因为您需要分析 dotMemory CLT 进程输出。

    所以,得到你需要的伪代码

    dotMemory.exe attach --service-output --use-api "your_app_PID"
    
    // then the message will be printed to output
    // ##dotMemory["connected",{"pid":your_app_PID,"name":"your_app_NAME.exe"}]
    wait for this message
    
    // the rest of your code remains the same
    // and you need only JetBrains.Profiler.Windows.Api.dll
    // no more need JetBrains.Profiler.Windows.SelfApi.dll
    if (MemoryProfiler.IsActive)
    {
        MemoryProfiler.Dump();
        MyMethodTobeProfiled();
        MemoryProfiler.Dump();
    }
    
    if (MemoryProfiler.CanDetach)
       MemoryProfiler.Detach();
    

    阅读更多关于 dotMemory 命令行分析器here

    【讨论】:

      猜你喜欢
      • 2014-02-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-07-20
      • 2013-02-14
      • 2014-12-03
      • 1970-01-01
      相关资源
      最近更新 更多