Page 1 of 1

Process WorkingSet64

Posted: Sat Mar 29, 2008 2:24 pm
by radnix
I wanted to document a potential leak situation that I resolved using .Net Memory profiler. If you see something incorrect here, feel free to correct me or provide better way. :)

Simple 2 second timer :

private void Timer_Tick(object sender, EventArgs e)
{
double phy_mem = Process.GetCurrentProcess().WorkingSet64;
......do stuff....
}

Profiling show ever increasing UnDisposed on real time graph. Taskmanager shows slight memory increase but seems to indicate garbage collector does handle it eventually.

Replacing the above process getcurrentprocess workingset64 line with:

using(System.Diagnostics.Process x = Process.GetCurrentProcess())
{
phy_mem = x.WorkingSet64;
}

Profiler real time graph for process clean, taskmanager shows no memory increase or fluctuation.

Nice...... 8)