|
George_George wrote: Do you agree?
I don't agree with your use of the word "consumed". Also that document while dated 2006 only discusses Windows NT 3.1 and 3.5. If the information has not actually been updated for later OS versions, it is likely that things have changed some. Also I am not sure what value this simple view of memory provides. Other articles/blogs discussions provide a far more detailed discussion regarding the complex matters of memory models in modern applications and platforms. Here is one example[^].
|
|
|
|
|
Thanks led,
The article gives me some insights. And I have also do some experiment to monitor memory of some process using perfmon.
Sometimes, I saw working set is larger than vitual memory. I am confused. How could it happen?
regards,
George
|
|
|
|
|
George_George wrote: I am confused. How could it happen?
Well one obvious way it could happen is lag. Lag could exist at various different places with the process of memory management all they way to the perfmon display. perfmon should not be considered real time I don't believe.
led mike
|
|
|
|
|
Hi led,
What in your definition and experience working set is? It is appreciated if you could share with us.
In my point, working set is the number of physical memory a process is currently using -- physical memory, not including page files.
regards,
George
|
|
|
|
|
George_George wrote: What in your definition and experience working set is? It is appreciated if you could share with us.
Well I have no reason to disbelieve what Salvador Patuel said in his blog.
Working set is the subset of virtual pages that are resident in physical memory only; this will be a partial amount of pages from that process.
he also said:
Note that this replacement policy has been optimized in windows Vista and Windows 2008 to keep more virtual pages on physical memory, that's why you can see that the free memory is lower in these OS.
So we can see that obviously not all OS version are going to be identical.
You still have not explained the significance of this information to you?
led mike
|
|
|
|
|
Thanks led,
Your reply is great! As you mentioned,
> Working set is the subset of virtual pages
So, working set has no reason to be larger than virtual bytes, right? (since it is a subset). But I have used perfmon to find sometimes working set is much larger than virtual pages.
I just did two experiements which shows working set is larger than virtual bytes,
1. a straightforward application which do file map, monitor my simple application;
2. do a search of keyword in my SourceInsight environment, monitor SourceInsight process.
Do you have any ideas when/why working set is larger than virtual bytes? If you are interested, I can post my simple application code here.
regards,
George
|
|
|
|
|
George_George wrote: Do you have any ideas when/why working set is larger than virtual bytes?
By definition a subset can not be larger than it's container set.
George_George wrote: I just did two experiements which shows working set is larger than virtual bytes,
If you really want to see that information stop using perfmon. From the same article.
You can explore the working set list using the kernel debugger
led mike
|
|
|
|
|
Thanks led,
led mike wrote: You can explore the working set list using the kernel debugger
My question is not and I am not interested to explorer the working set list. But wondering why working set could be larger than virtual bytes.
I have written a program to show my idea. I have tested it under Windows Server 2003. If you are interested, here I can share with you. You can monitor the working set counter and virtual bytes counter and you can find working set is much higher than virtual bytes.
int main(int argc, char* argv[])
{
LARGE_INTEGER start,end;
LARGE_INTEGER freq;
QueryPerformanceCounter(&start);
QueryPerformanceFrequency(&freq);
MEMORYSTATUS memstat;
void** map;
int sectionIndex = 0;
memstat.dwLength = sizeof(memstat);
GlobalMemoryStatus(&memstat);
long long size = 512*1024*1024;
HANDLE mapping =
CreateFileMapping(NULL,NULL,PAGE_READWRITE|SEC_COMMIT,(DWORD)(size>>32),DWORD(size),NULL);
if (mapping)
{
SYSTEM_INFO sysInfo;
GetSystemInfo(&sysInfo);
const int allocSize = sysInfo.dwAllocationGranularity;
GlobalMemoryStatus(&memstat);
void *mem = new char[allocSize];
memset(mem,0x11,allocSize);
map = (void**) new char [sizeof(void*) * size / allocSize];
for (int i=0; i<10; i++)
{
sectionIndex = 0;
for (long long offset=0; offset<=size-allocSize; offset+=allocSize)
{
map [sectionIndex] =
MapViewOfFile(mapping,FILE_MAP_WRITE,(DWORD)(offset<<32),(DWORD)offset,allocSize);
if (map [sectionIndex])
{
memcpy(map [sectionIndex],mem,allocSize);
}
sectionIndex++;
}
for (sectionIndex = 0; sectionIndex < size/allocSize; sectionIndex++)
{
if (map [sectionIndex])
{
UnmapViewOfFile(map [sectionIndex]);
}
}
GlobalMemoryStatus(&memstat);
sectionIndex = 0;
for (long long offset=0; offset<=size-allocSize; offset+=allocSize)
{
map [sectionIndex] =
MapViewOfFile(mapping,FILE_MAP_READ,(DWORD)(offset<<32),(DWORD)offset,allocSize);
if (map [sectionIndex])
{
for (int t=0; t<allocSize; t++)
{
if (((char *)(map [sectionIndex]))[t]!=0x11)
{
OutputDebugString("Memory read failed\n");
}
}
}
UnmapViewOfFile(map [sectionIndex]);
}
GlobalMemoryStatus(&memstat);
}
QueryPerformanceCounter(&end);
GlobalMemoryStatus(&memstat);
printf("Time %.3f\n",
double(end.QuadPart-start.QuadPart)/double(freq.QuadPart));
CloseHandle(mapping);
delete[] mem;
GlobalMemoryStatus(&memstat);
}
return 0;
}
regards,
George
|
|
|
|
|
Did you see performance example on the MSDN,it shows to you detailys that you need and you can see its code that you need.
|
|
|
|
|
Could you provide a link please, Hamid?
regards,
George
|
|
|
|
|
|
Hi Hamid,
The sample only tells you how to read specified counter using VB, but my question is what is the meaning of memory related counter for a process, like private bytes, virtual bytes, working set and page file bytes. Any ideas?
regards,
George
|
|
|
|
|
|
Thanks Hamid!
Very good link. I think private byte only includes the RAM, not including the page swap file, right?
regards,
George
|
|
|
|
|
i have a check box and an edit box in my application. the edit box displays values from 1 to 100. and there is a timer which helps to display all the values. when i click on the check box the values should get logged in to a file. i am only getting the last digit. i need the value from the moment i check the check box. and when i uncheck it it should stop loggin. what needs to be done. i think i need to use a while loop. is that right?
|
|
|
|
|
What type of project are you working at?
MFC or Win32 SDK?
Maxwell Chen
|
|
|
|
|
|
Have a global boolean flag declared and set its value to true/false after the user is clicking on the checkbox. Modify the code which updates the value in edit control to check for true state of boolean flag. If the flag is true, append the present value to your log file.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
...formerly known as brahmma
Codeproject.com: Visual C++ MVP
|
|
|
|
|
Did you have any code for save previous values of edit ctrl?
|
|
|
|
|
If I understood your requirement correctly, you can do it by the following steps...
1. Create a control variable of type CButton
2. In the timer function, by using (m_check.GetCheck() & BST_CHECKED) you can identify the state.
3. If it is checked then log the value.
|
|
|
|
|
NS17 wrote: 2. In the timer function, by using (m_check.GetCheck() & BST_CHECKED) you can identify the state.
Since the GetCheck() method can only return one of three values, why use the bitwise AND operator rather than just check for equality?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
DavidCrow wrote: why use the bitwise AND operator rather than just check for equality?
Yes. It's a mistake.
|
|
|
|
|
NS17 wrote: Yes. It's a mistake.
No. In fact it isn't, because you're lucky guy. However checking for equality is more appropriate.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|
|
CPallini wrote: However checking for equality is more appropriate.
Yes, I know bitwise AND will work. But ofcourse as you said checking for equality is more appropriate.
|
|
|
|
|
NS17 wrote: Yes, I know bitwise AND will work
Because there are wise guys at Microsoft.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
[my articles]
|
|
|
|