0

Possible Duplicate:
What strategies and tools are useful for finding memory leaks in .NET?

I have a program that gives an "Out of memory" exception after running for a while. It's a fairly complex program, and involves quite a lot of async stuff. Rather than diagnose the problem by starting from the code, I thought it might give me a head-start if I could tell which objects were cluttering up the memory that's not getting garbage-collected.

Is there a way to do this?

Community
  • 1
  • 1
Gary McGill
  • 26,400
  • 25
  • 118
  • 202
  • Have a look at this question: http://stackoverflow.com/questions/134086/what-strategies-and-tools-are-useful-for-finding-memory-leaks-in-net – Bob Kaufman Sep 30 '12 at 16:27

3 Answers3

0

Even though you can use a profiler to check the objects, sometimes you cannot change your logic accordingly when you have lot of async stuffs baked in.

Generally we make memory leaks unknowingly by using Event handler patterns.

I have some posts regarding this : http://www.codeproject.com/Articles/123448/GC-Algorithm-and-Story-of-WeakReference

http://www.abhisheksur.com/2012/02/optimizing-inpc-objects-against-memory.html

They are not specific to your problem, but it can help you.

abhishek
  • 2,975
  • 23
  • 38
0

I would definitely use a profiler, one of the best ones I've used for memory profiling is SciTech's memory profiler Scitech .NET Memory Profiler

NeddySpaghetti
  • 13,187
  • 5
  • 32
  • 61
0

If your are using threading to async your code control on thread like run specific thread simultaneously for example run only 10 thread simultaneously after completion of this run next 10 thread and if you are creating any unmanaged object dispose it explicitly

Shyam
  • 31
  • 1