2

I have a wpf application that is leaking memory...is there a way to detect and fix these leaks using just visual studio without using any of the profiling tools? Or are there any free ones that I could use to detect and fix them? Thaks

user1202434
  • 2,243
  • 4
  • 36
  • 53
  • 5
    how did you know it is leaking memory ? – Shyju Jun 12 '12 at 18:06
  • I run the application, open up a few windows with controls, close them ... the memory in the task manager just keeps up...I tried to programmitcally call GC.Collect()..at different points...that dosent clean up the controls... – user1202434 Jun 12 '12 at 18:07
  • Since .NET is managed it shouldn't leak - although you can't be sure when the GC will kick in – m.edmondson Jun 12 '12 at 18:09
  • 1
    Be sure to call `Dispose` on any disposable objects. Also understand that explicitly calling `GC.Collect()` doesn't necessarily mean that the GC will run right then and there. – doogle Jun 12 '12 at 18:10
  • 1
    possible duplicate of [Memory leaks in wpf C#](http://stackoverflow.com/questions/6154810/memory-leaks-in-wpf-c-sharp) – sloth Jun 12 '12 at 18:10
  • I would avoid calling GC.Collect() also. Let .net manage that for you. – tsells Jun 12 '12 at 23:44
  • Look at these SO question's for profiling tools and yes most of the tools have free trial period - http://stackoverflow.com/questions/399847/net-memory-profiling-tools and http://stackoverflow.com/questions/1312493/net-code-profiling-tools?rq=1 – akjoshi Jun 13 '12 at 06:21

3 Answers3

1

Scitech's memory profiler has a free trial period and is an excellent tool for investigating memory consumption issues.

Ian Mercer
  • 38,490
  • 8
  • 97
  • 133
1

You can investigate memory leak only for application written in C++ in Visual Studio, take a look here at the official documentation ...

aleroot
  • 71,077
  • 30
  • 176
  • 213
1

Have a look at this answer, which provides some links with useful information.

You'll basically need the SOS debugger extension.

Community
  • 1
  • 1
sloth
  • 99,095
  • 21
  • 171
  • 219