ANTS Memory Profiler 8

Profiling a Windows service

Profiling a Windows service will restart the service. If you don't want to restart the service, use Attach to a .NET 4+ process. See Attaching to a process.

To profile a Windows service:

  1. Start ANTS Memory Profiler and click New profiling session
  2. From the list of application types, select Windows service.
  3. Select the service you want to profile from the drop-down list.
    If the service is running but isn't in the list, click Refresh

  4. If you want to enter arguments for the service to use, click Show startup options:
    Windows service startup options 
    If the service takes a long time to start or stop, increase the Timeout. This is the length of time, in seconds, that ANTS Memory Profiler will wait for the service to start or stop.
    If service timeouts continue to occur even after increasing the timeout, you may need to increase the Windows timeout. 
  5. If you want to record extra performance counters, click Edit counters and select the counters you want.
    Move your mouse pointer over a performance counter to read more about it.
    For more information about performance counters, see Setting up performance counters.
  6. Under Additional profiler options:
    1. Select Profile child processes to include any processes created by your service in profiling. 
      If your application has lots of child processes, this option will slow down your service.
    2. Select Track disposal of IDisposable objects to keep track of when IDisposable objects in your application are disposed.
      This option will slow down your service slightly.
    3. Select Profile unmanaged memory allocations if your application access unmanaged memory through P/Invoke or COM+, and you want to profile the unmanaged memory that your application uses.
      (Not available in Windows XP / Server 2003 and earlier, or when profiling .NET 1.1 applications.)  

      This option will slow down your service by up to fifty percent, because a lot of additional information is being tracked.

    4. Select Make snapshots faster by leaving out object values if you've had problems with snapshots being too slow or too large.
      You won't be able to see the values of individual instances, but references between objects aren't affected.
      If you want to see the values of strings or the contents of arrays specifically, click Customize and deselect the relevant option.
  7. Click  Start profiling
    The main profiling window is displayed, and the service will start. 
    On the timeline, you can see the memory being used by your program, along with any other performance counters you selected.
  8. When the service is in a stable state (ie is fully started up and ready for normal use), click 
    A memory snapshot gives you a detailed breakdown of the memory being used at that point in time, so that you can compare it with later snapshots. 
  9. When you've taken at least two snapshots, you can start to investigate your service's memory usage. See Strategies for memory profiling.

If you experience problems, see Profiling a Windows service fails if the service uses a system account.


Didn't find what you were looking for?