Reputation: 781
Actually I am working on real-time application with multiple threads.
While I am running my application memory is 65 Mb and if I open a child MDI form then memory increases to 85mb but if I close the child window then memory will still remains at 85mb.
I have used Dispose and I've already tried with GC.Collect(), but none of these solve my problems, so I am little bit confused regarding this issue.
Can you please guide me regarding this?
Thanks in advance.
Upvotes: 0
Views: 696
Reputation: 1
The task manager memory number is not always as sharp as it would be, however this small trick can cheat that number... Not meant for production.
public static void RefreshMemory() {
try {
Process curProc = Process.GetCurrentProcess();
curProc.MaxWorkingSet = curProc.MaxWorkingSet;
} catch {
// Handle the exception
}
}
Upvotes: 0
Reputation: 1013
Does the memory increase every time you open a new child window? If so, open and close several of these and then attach to the process using windbg.
After loading sos, you can use the !dumpheap command to get an idea of where the memory leak might be and then use gcroot to find where the leaked memory's is rooted.
This blog might help: http://blogs.msdn.com/b/delay/archive/2009/03/11/where-s-your-leak-at-using-windbg-sos-and-gcroot-to-diagnose-a-net-memory-leak.aspx
Btw, how are you writing a "real-time application" in c#?
Upvotes: 0
Reputation: 17556
have you used some global delegate references in your child MDI form?
Upvotes: 0
Reputation: 24232
You need to get a good memory profiler.
There are a bunch of options:
Many cost money (except CLR Profiler) but usually have trial versions.
After you start your app (with the profiler attached), you need to take snapshots of the memory before the leak and after and compare them to see what is staying around.
It's hard to say what the problem might be in your case, since there are many things that could be causing the problem.
Upvotes: 2