views:

482

answers:

7

Are there any good(and free) tools for either analyzing static source or running programs to help detect memory leaks?

I've built some windows services and want to make sure the are not going to consume memory if I leave them running for weeks on end.

+2  A: 

Doesn't meet your requirements of being free, but there's one by Red Gate I think is worth suggesting - ANTS Memory Profiler

I've used a number of their tools before (some on trial, some we've bought) and found them to be very good.

AdaTheDev
+1  A: 

Redgate Ants Performance Profiler might help. It isn't free... but there is a 14 day trial which may be enough to get your services working.

DeletedAccount
A: 

Profile Sharp is a free (open-source) performance and memory profiler for .NET

Philippe Leybaert
+1  A: 

Let your service run and use Performance Monitor to collect information about the memory usage of the service. Also, if you use any unmanaged resources make sure your code properly disposes of these resources using IDisposable. In an unmanaged environment you can easily have leaks by simply forgetting to release pointers, but that is not possible in a managed environment. However, if you keep allocating new objects and keep references to them so they cannot be garbage collected your service will require more and more memory.

Martin Liversage
+1  A: 

I've used Microsoft's CLR Profiler with some success. Make sure to read its documentation to get the full benefits.

Richard Morgan
A: 

Don't forget that you can use the Windows Task Manager to detect at least the presence of memory leaks in your service.

Another way to use the Task Manager to track objects it to switch to the Processes tab, then go to View > Select Columns and check USER Objects and GDI Objects (GDI probably not useful to you since you're running a Service, but others may find it useful.)

bufferz
+2  A: 

I can recommend http://memprofiler.com/, but it is not free.

Lars Truijens