![]() |
Virtual, Private Bytes and Working Set |
Post Reply
|
Page 12> |
| Author | |
tvlad
Newbie
Joined: 17 March 2009 Online Status: Offline Posts: 6 |
Post Options
Quote Reply
Topic: Virtual, Private Bytes and Working SetPosted: 27 April 2010 at 5:45pm |
|
I was reading this blog post : http://blogs.msdn.com/ricom/archive/2005/08/01/446329.aspx which says in the beginning that private bytes represent the space allocated in the swap file to eventualy hold the contents of the private memory if swapped out.
It then goes on to say that private bytes shared between processes are in the physical memory, which is confusing, looks like 2 contradictory statements, at least from my understanding.
My understating now of private bytes is that they generaly represent the private pages of the process.
Those private pages can be some in RAM and some on the DISK.
Thanks,
Vlad
|
|
![]() |
|
99sono
Newbie
Joined: 01 November 2009 Location: Portugal Online Status: Offline Posts: 2 |
Post Options
Quote Reply
Posted: 01 November 2009 at 8:10pm |
|
By the way, let me try to give some driect answers regarding your questions; but keep a Critical EYE to whatever i Say:
I am not a Windows Expert. Still, the information you are seeking can be most useful in a varied number of situations, and that is why I can try to answers your questions. Anyway: "1) private pages are pages that belong only to that respective process ?" Not really, but still: sort of. The answer is: yes in most cases, but false for some exceptions. For example, If you start running two processes from the same executable, the "Source Code" is a common denominator for both applications. Is it not? So, naturally, if you consider the following function: f_map_commited_bytes_to_phyfical_addres(virtuaLaddress), And you feed the virtual address of a source code instruction: the mapping to a physical address will be the same for both processes. Illusrtation: 1) if that address is on a Ram Page, neither process will incur in a cache miss when it has to run the Instruction. 2) If for some reason process Process_A had a code page swapped out, and process Process_B happens to be needing that code block: process B will need to swap it back in. So no! The answer is no. The private Bytes include subset of addres that you could call shared code. Ironic, no? My private bytes can after all be shared? It seems that way, i believed they are called private bytes simply because they belong to the User Address Space, that is intuitively private to your application. While the kernel code, also in the address space of your application, is public to everybody. And since shared code implies: different processes but same mapping function to those addresses: not all private pages belong uniquely to that process. " 2) - reserved pages are pages reserved for the process, which when
commited to memory will show up in the working set of the process which
shows the physical memory allocated to the process ?"
Nope. Most of the time the most part of your commited memory/ private bytes, are not in the working set: they are well rested on disk just waiting for a cache miss to happen. Check your Msm Live messenger for instance, with the process explorer tool that i mentioned, you will see that it has like 50 MB private bytes, and at some time sthe working set is just 3 MB. Highly inefficient by the way. And all those private bytes are Commited memory. "3)Also, what I don't understand very well is where all the pages are being stored.
Am I correct in saying that:
- private pages can be both in virtual and physical memory"
They Are all in virtual memory! I hate the mix up between virtual memory and swap file usage. There is not a single address of code that is not virtual memory. It just so happens that some of it is in ram, and some of it is in disk - wish is normally swap memory. Calling swap memory virtual memory is IMO Horrible! It just serves to cause entropy of concepts. Let virtual memory mean and address that is fed to an OS function that can dynamically determine the resting place of your data, and swap memory refer to what you use to extend your ram capacity. But answering the question: YEs, are right, it can be either on physical memory AKA RAm, or in Swap File, or even on Disk but not in the swap file :D. Swap File is disk space, but again, you don't need a swap file to have some of your private pages on disk. Try disabling the Windows swap File. You get less cache misses, oh, but you will still get cache misses nonetheless. "- reserved pages in virtual memory" Reserved pages are simply a set of address numbers that can not be alocated any longer. Best Regards. Edited by 99sono - 01 November 2009 at 8:39pm |
|
|
Americans speak about socialism as if It was a crime?Yet Norway has high taxes,pub health care,pub education, and the highest standard of living!I'll keep my taxes and you can keep watching fox news!
|
|
![]() |
|
99sono
Newbie
Joined: 01 November 2009 Location: Portugal Online Status: Offline Posts: 2 |
Post Options
Quote Reply
Posted: 01 November 2009 at 7:43pm |
|
Windows memory managment has way too many concepts, and explained in a way too unclear in almost every page - official or not. Still, you can find some good pages describing some of these concepts: 1) http://www.piclist.com/tecHREF/os/win/api/win32/sys/src/memman.htm 2) http://www.tenouk.com/WinVirtualAddressSpace.html You should also download the windows tool called "process explorer" developed by sysinternals, if I am not mistaken. It will help you clear out, in a visual way, some of the doubts. You want to track the memory used by one of your processes, namely you wanna check how much ram it is consuming. You can use the task manager for that. Ctrl Alt Del, task manager, search for your process, that's it. The task manager is showing you the working set. Officially, Microsoft says that the working set is a set of pages that have recently been accessed by your process. Unofficially, you can open the process explorer, click on a process you wish to monitor, go into to the performance tab, and you will see that the "Working Set" statistics is listed under the Physical Memory section of the performance counters. As for the private memory of a program, I think that I am not mistaken if I say that is whatever "user code" or "user data" that your application has committed in "user virtual address space". When your program starts up the Virtual address space is 4 GB for a 32 bits system. Slash 2 GB out which are reserved for kernel code and buffers, and you are left with 2 GB of virtual address space. Most of that address space the average application does not use. A fraction of those 2 GB user address space are reserved. I believe that the Reserved memory of your application is equal to what you call: Virtual Size. A subset of this reserved memory is actually being used by your application. And that fraction of address spaces - keep in mind it is still a subset of the reserved memory - is what you call "committed memory" or if your prefer "private memory". I believe that the commited memory does not include any memory inside the Kernel Address Space. I may be wrong here. If it is not: Committed Memory <=> Private Memory. Now, committed memory could be anything. It is implicit from what I said be fore that committed memory is: the set address that contain application code, it is the set of addresses that contain your application buffers, it is the set of addresses that contain your dll code of your application has loaded, etc... it is everything that you are application depends on to run (with the exception of all the addresses that belong to the kernel addres space). So, rather often, when you check the statistics of a running process you may see a Huge virtual Size (2GB tops). That could because, for example, a Database System knows that its buffer manager cache can have a size varying from 10 MB to 200 MB. You could reserve 200MB and commit 10. For instance. More importantly, the Virtual Memory size of your process does not tell you an awful lot of the resources it consumes. Then you have the private bytes of your process. Now this matters, all those address in the private bytes probably have to have entries in the Windows Page Table. If you rever to any address of your private address space, windows has got to be able to track there location. Either on swap, or if you are lucky, directly on ram. And Finally, an amount of memory, typically smaller than your private size, constitutes your Working Memory. i believe that your working memory could - hypotethically - be bigger than your private size, assuming that your application is using lots of Kernel Code, for doing whatever. Another Interesting thing, you can tune your Operating System and disable Windows Swap File. Which is something I like to do in any machine with more than 1 GB of ram. Because windows may swap out pages even when a lot of Ram/physical memory is free. Even so, even if you tune your system to not use a Page File, you will see that a lot of cache misses an disk I/O continues to occur. This is because, even with a page file, a lot of resources that comprise an application can be "swaped out". You application Code, that does not change, your Program Constants, etc... Pages containing these types of data can, at any time, be removed from your physical memory (they are not written to disk - because what they are in disk is just fine). But well, this last paragraph is just ranting. Anyway, I don't know if i managed to Help. Best Regards. Edited by 99sono - 01 November 2009 at 8:58pm |
|
|
Americans speak about socialism as if It was a crime?Yet Norway has high taxes,pub health care,pub education, and the highest standard of living!I'll keep my taxes and you can keep watching fox news!
|
|
![]() |
|
tvlad
Newbie
Joined: 17 March 2009 Online Status: Offline Posts: 6 |
Post Options
Quote Reply
Posted: 05 May 2009 at 11:14am |
|
Let me try and restate what I understand and what I don't so far.
Virtual Bytes is the total size of the non-free pages in a process' virtual address space. This includes private, image,mapped and reserved pages
Private Bytes is the total size of the private pages.
The Working Set counter reports the amount of committed memory allocated to the process. This might include shared and private bytes currently residing in physical memory
Am I correct in saying that :
- private pages are pages that belong only to that respective process ?
- reserved pages are pages reserved for the process, which when commited to memory will show up in the working set of the process which shows the physical memory allocated to the process ?
Also, what I don't understand very well is where all the pages are being stored.
Am I correct in saying that:
- private pages can be both in virtual and physical memory
- reserved pages in virtual memory
Can you please give me a basic definition for image and mapped pages ?
Thanks,
Vlad
|
|
![]() |
|
wj32
Senior Member
Joined: 16 January 2009 Location: Australia Online Status: Offline Posts: 704 |
Post Options
Quote Reply
Posted: 15 April 2009 at 11:01am |
|
Ah, thank you for the correction.
|
|
|
MCTS: Windows Internals
Process Hacker, a free and open source process viewer. |
|
![]() |
|
dsolomon
Newbie
Joined: 01 July 2007 Location: United States Online Status: Offline Posts: 19 |
Post Options
Quote Reply
Posted: 13 April 2009 at 7:25pm |
|
"Virtual Bytes is the total size of the non-free pages in a process' virtual address space. This includes private, image and mapped pages."
This also includes RESERVED pages - for a quick demo, use Testlimit (from the Windows Internals book page on Sysinternals) and do a "testlimit -r" - this reserves all the address space it can get.
Then view the process virtual bytes and you'll see (running the 32-bit testlimit) it nearly 2GB, while private bytes will be tiny.
However, if you do a "testlimit -m", this COMMITS the virtual addresses and you'll see private bytes (and virtual bytes) nearly 2GB.
In my Windows Internals class, I do a demo where I have everyone add to Process Explorer the virtual bytes, private bytes, working set total, private, shared, & shareable and run testlimit twice: once with "-m" and again with "-r". Fyi, the "-d" switch commits and then touches each page, forcing the system to actually create the zero initialized pages - with that one, the working set will grow like crazy, forcing the system to utilize nearly all of the paging cache [aka standby lists], trim other process working sets, which in turn dumps pages to the modified list, which in turn initiates a bunch of out paging... fun!
-Dave Solomon
|
|
|
--David Solomon
Coauthor, Windows Internals (Microsoft Press) http://www.solsem.com |
|
![]() |
|
schs
Newbie
Joined: 28 May 2008 Online Status: Offline Posts: 26 |
Post Options
Quote Reply
Posted: 10 April 2009 at 12:47pm |
|
Pages sharing is not related to their disposition. In general, any page can be swapped.
Shared pages are just those, which can be used in memory sharing. |
|
![]() |
|
kfh
Newbie
Joined: 10 April 2009 Online Status: Offline Posts: 1 |
Post Options
Quote Reply
Posted: 10 April 2009 at 12:03pm |
![]() |
|
tvlad
Newbie
Joined: 17 March 2009 Online Status: Offline Posts: 6 |
Post Options
Quote Reply
Posted: 10 April 2009 at 9:11am |
|
UP!
|
|
![]() |
|
tvlad
Newbie
Joined: 17 March 2009 Online Status: Offline Posts: 6 |
Post Options
Quote Reply
Posted: 06 April 2009 at 4:18pm |
|
Thanks for the reply wj32
The reason for the ambiguos terms is because the whole thing is not very clear to me.
Private pages are the pages for the process itself. Are private pages resident in Ram only ?
Mapped pages for me are pages that are swapped, and maybe share with other processes. Are shared pages resident in Swap only ?
What do you mean by image pages
Thanks,
Vlad
|
|
![]() |
|
Post Reply
|
Page 12> |
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |