Help!! How can I get the information of memory used by a process??

L

Lyon

Here is a part of my code:

internal bool Excute(string input)
{

ProcessStartInfo psi = new ProcessStartInfo();
psi.FileName = this.filePathToExcute;

psi.RedirectStandardOutput = true;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.UseShellExecute = false;

Process p = new Process();
p.StartInfo = psi;

p.ErrorDataReceived += new
DataReceivedEventHandler(p_ErrorDataReceived);
p.OutputDataReceived += new
DataReceivedEventHandler(p_OutputDataReceived);
p.Start();

//peakMemory = p.PeakWorkingSet64;//It is the right place
to get the information of memory used by the process p here??

p.BeginOutputReadLine();
p.BeginErrorReadLine();

p.WaitForExit(2000);

if (!p.HasExited)
{
p.ErrorDataReceived -= new
DataReceivedEventHandler(p_ErrorDataReceived);
p.OutputDataReceived -= new
DataReceivedEventHandler(p_OutputDataReceived);

p.Kill();
p.Close();

return false;
}

excuteTime = p.TotalProcessorTime;
peakMemory =p.PrivateMemorySize64;//And again. It is the
right place to get the information of memory used by the process p
here??


/* NonpagedSystemMemorySize64=p.NonpagedSystemMemorySize64;
PagedMemorySize64=p.PagedMemorySize64;
PagedSystemMemorySize64=p.PagedSystemMemorySize64;
PeakPagedMemorySize64=p.PeakPagedMemorySize64;
PeakVirtualMemorySize64=p.PeakVirtualMemorySize64;
PeakWorkingSet64=p.PeakWorkingSet64;
PrivateMemorySize64=p.PrivateMemorySize64;
VirtualMemorySize64=p.VirtualMemorySize64;
WorkingSet64 = p.WorkingSet64;

*/ //Here are so many memory information related properties of the
process, and which one is the physical memory used by the process p??

p.Close();
}
Thank you very much!

A confused boy is lingering to find the information of physical memory
used by the process.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top