views:

66

answers:

4

I have an issue where my application runs fine for hours but then suddenly increases memory usage (in a matter of minutes) until it crashes. If we minimize the application during the increasing memory usage, the memory goes way down and stays down for a while. This seems to happen very inconsistently. Any idea how to troubleshoot it/what the cause might be?

A: 

We need more info like are you using any resources like a database connection. Are you using the using statement or try catch finally to ensure that your db connection is cleaned up?

Is it a file resource based application? We need more info and maybe sample code ?

JonH
No database or files. We're using a lot of BackgroundWorker threads for non-UI work, however.
Sadhana
+2  A: 

There are plenty of tools to help you detect that sort of problem. Try ANTS Memory Profiler or WinDbg + SOS.

ANTS allow you to take snap shots and compare them. That will help you spot what is taking up the additional memory.

WinDbg allows you to inspect the heap. The !dumpheap command is useful. Look for unexpected number of instances. To examine why objects are not reclaimed by the GC use the !gcroot command. Take a loot at Tess' blog for more info on WinDBg + SOS.

Brian Rasmussen
A: 

You have to get a memory tacker/debugger to narrow the research

Eric
+1  A: 

You are looking at the wrong memory diagnostic if you see it decrease significantly when you minimize the app's main window. That's the working set, the amount of virtual memory that's mapped to RAM. Working set is always variable, it largely depends what other processes are running and need to have their own pages mapped to RAM. An app bombs on OOM when it runs out of free virtual memory, an entirely different number.

Yes, use a good memory profiler to avoid making conclusions that don't help you diagnose the problem.

Hans Passant