2

I'm running dotMemory command line against an IoT Windows Forms application which requires many hours of tests on a custom appliance.

My purpose is to get memory snapshots on a time basis, while the application is running on the appliance. For example, if the test is designed to run for 24h, I want to get a 10 seconds memory snapshot each hour.

I found 2 ways of doing it:

  1. Run dotMemory.exe and get a standalone snapshot on a time basis, by using schtasks to schedule each execution;
  2. Run dotMemory using the attach and trigger arguments and get all the snapshots on a single file.

The first scenario it's ready for me, but as it is easy to see, the second one is much better for further analysis after collecting the data.

I'm able to start it by using a command just like:

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

Here comes my problem:

  • How can I make the command/process stop after it reaches the max-snapshot value without any human intervention?

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

1 Answers1

1

If you start your app under profiling instead of attaching to the already running process, stopping the profiling session will kill the app under profiling. You can stop profiling session by passing ##dotMemory["disconnect"] command to the dotMemory console stdin. (E.g. some script can do that after some time).

See dotmemory help service-messages for details

##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. Some notes about your command line. With this comand line dotMemory will get a snapshot each 10 seconds but will start to do it after one hour. There is no such thing as "10 seconds memory snapshot" memory snapshot is a momentary snapshot of an object graph in the memory. Right command line for your task will be C:\dotMemory\dotMemory.exe attach $processId --trigger-on-activation --trigger-timer=1h --trigger-max-snapshots=24 --save-to-dir=c:\dotMemory\Snapshots

Ed Pavlov
  • 2,353
  • 2
  • 19
  • 25
  • Thanks Ed.ward! About what you said: "E.g. some script can do that after some time". This is something I'm looking for, if you know a way of doing it, please share with me. This is the exact issue, how to send the `##dotMemory["disconnect"]` message to the dotMemory running process stdin without making it manually? The command line I've sent was just an example of how I'm doing it. – José Luiz Arantes May 14 '21 at 14:15
  • You can do that from C# progam using Process.Start to start dotMemory.exe. Or use powershell script as it described in this post. https://stackoverflow.com/a/16100200/779822 – Ed Pavlov May 17 '21 at 10:23
  • Also it's possible to use a file on disk as an input. Use use `--service-input=path\to\your.file` command, and then write commands to this file using any approach you like. – Ed Pavlov May 17 '21 at 11:33