473,396 Members | 1,599 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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

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.NonpagedSystemMemoryS ize64;
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.

Nov 21 '06 #1
2 5695
Hi,
A confused boy is lingering to find the information of physical memory
used by the process.
The documentation on MSDN is thorough - I found the answer quickly here:

"Process.PeakWorkingSet64"
http://msdn2.microsoft.com/en-us/lib...64(VS.80).aspx

--
Dave Sexton

"Lyon" <zl*****@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
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.NonpagedSystemMemoryS ize64;
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.

Nov 21 '06 #2
Thank you very much!!

"Dave Sexton дµÀ£º
"
Hi,
A confused boy is lingering to find the information of physical memory
used by the process.

The documentation on MSDN is thorough - I found the answer quickly here:

"Process.PeakWorkingSet64"
http://msdn2.microsoft.com/en-us/lib...64(VS.80).aspx

--
Dave Sexton

"Lyon" <zl*****@gmail.comwrote in message
news:11**********************@j44g2000cwa.googlegr oups.com...
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.NonpagedSystemMemoryS ize64;
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.
Nov 22 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Avi Kak | last post by:
Hello: My apologies in advance for asking a question that probably has been raised numerous times already in this newsgroup. My Google search did not lead me to an answer I could use. Is...
7
by: Rich Denis | last post by:
Hello, I have been trying to solve a mysterious memory leak problem and was hoping that you could help me out on my stuck point. First a bit of background. We have two app servers in an app...
2
by: Asfar | last post by:
Hi, I have a VS2005 windows program written in c#. In this program I have an array list which stores many DataTable's. When I first run the pogram the arraylist is loaded with datatables. At...
3
by: Avi | last post by:
Hi all, In my program I need to know the memory used by certain applications. I was able to get the free available memory on the machine, but not the memory that is used by a specific...
0
by: Lyon | last post by:
Here is a part of my code: internal bool Excute(string input) { ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = this.filePathToExcute; psi.RedirectStandardOutput = true;...
1
by: Andrew McLean | last post by:
I want to script the benchmarking of some compression algorithms on a Windows box. The algorithms are all embodied in command line executables, such as gzip and bzip2. I would like to measure three...
5
by: Sune | last post by:
Hi all, I want to make data stored in-memory (not disk) available to several processes. My concern is that poorly written C applications with dangling pointers may(will) damage the data in this...
3
by: mohi | last post by:
hello everyone , is there any cmmnd in gdb or any other way to find out whats the total dynamically allocated memory a process holds at various instances of execution??? and what can be the...
3
by: Salim Fadhley | last post by:
I'm trying to create a python unit-test which will test a complex program which includes a number of functions which have been implemented in C or C++. The unit-test needs to check that after...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.