I have a problem with my program and its function is to display on the screen how much RAM the process is consuming at the moment and display the peak of ram usage, so my problem is when I close the process, the program to display the peak of ram memory.
Here is the part of the code that displays the peak of ram memory:
public string vmax()
{
System.Diagnostics.Process[] ieProcs = Process.GetProcessesByName(label92.Text);
double avvv = 0;
string abi = null;
try
{
if (ieProcs.Length > 0)
{
foreach (System.Diagnostics.Process p in ieProcs)
{
String physicalMem = p.PeakWorkingSet64.ToString();
abi = physicalMem;
}
}
avvv = double.Parse(abi);
avvv = avvv * 0.001 / 1024;
return avvv + " K";
}
catch
{
return "";
}
}
private void timer1_Tick(object sender, EventArgs e)
{
label90.Text = vmax();
}
With the calculator process open:
Withthecalculatorprocessclosed:
I wanted that even when I closed the process it would still display the last value recorded by the peak.