Working Set Private

Working Set Private




👉🏻👉🏻👉🏻 ALL INFORMATION CLICK HERE 👈🏻👈🏻👈🏻




















































Sign up or log in to view your list.
I am trying to use the perfmon windows utility to debug memory leaks in a process.
This is how perfmon explains the terms:
Working Set is the current size, in bytes, of the Working Set of this process. The Working Set is the set of memory pages touched recently by the threads in the process. If free memory in the computer is above a threshold, pages are left in the Working Set of a process even if they are not in use. When free memory falls below a threshold, pages are trimmed from Working Sets. If they are needed they will then be soft-faulted back into the Working Set before leaving main memory.
Virtual Bytes is the current size, in bytes, of the virtual address space the process is using. Use of virtual address space does not necessarily imply corresponding use of either disk or main memory pages. Virtual space is finite, and the process can limit its ability to load libraries.
Private Bytes is the current size, in bytes, of memory that this process has allocated that cannot be shared with other processes.
Is it the Private Bytes which I should measure to be sure if the process is having any leaks as it does not involve any shared libraries and any leaks, if happening, will come from the process itself?
What is the total memory consumed by the process? Is it the Virtual Bytes or is it the sum of Virtual Bytes and Working Set?
Is there any relation between Private Bytes, Working Set and Virtual Bytes?
Are there any other tools that give a better idea of the memory usage?
pankajt
pankajt 7,144●1111 gold badges●3434 silver badges●5959 bronze badges
Jeffmagma
362●11 gold badge●77 silver badges●1616 bronze badges
A better tool would be valgrind/helgrind, but not under Windows unfortunately :( – Kornel Kisielewicz Dec 31 '09 at 6:24
Is it the private byte should I measure to be sure if the process is having any leak If private bytes of a process don't grow then you have no memory leaks. If they grow it might be due to memory leaks and it might be due to memory fragmentation. I think it is difficult to say looking at growth of private bytes what it means exactly. – user184968 Dec 31 '09 at 7:08
@SergeiKurenkov One thing we can say is that it would NEVER be due to "memory fragmentation". – Jamie Hanrahan Nov 10 '18 at 8:27
The short answer to this question is that none of these values are a reliable indicator of how much memory an executable is actually using, and none of them are really appropriate for debugging a memory leak.
Private Bytes refer to the amount of memory that the process executable has asked for - not necessarily the amount it is actually using. They are "private" because they (usually) exclude memory-mapped files (i.e. shared DLLs). But - here's the catch - they don't necessarily exclude memory allocated by those files. There is no way to tell whether a change in private bytes was due to the executable itself, or due to a linked library. Private bytes are also not exclusively physical memory; they can be paged to disk or in the standby page list (i.e. no longer in use, but not paged yet either).
Working Set refers to the total physical memory (RAM) used by the process. However, unlike private bytes, this also includes memory-mapped files and various other resources, so it's an even less accurate measurement than the private bytes. This is the same value that gets reported in Task Manager's "Mem Usage" and has been the source of endless amounts of confusion in recent years. Memory in the Working Set is "physical" in the sense that it can be addressed without a page fault; however, the standby page list is also still physically in memory but not reported in the Working Set, and this is why you might see the "Mem Usage" suddenly drop when you minimize an application.
Virtual Bytes are the total virtual address space occupied by the entire process. This is like the working set, in the sense that it includes memory-mapped files (shared DLLs), but it also includes data in the standby list and data that has already been paged out and is sitting in a pagefile on disk somewhere. The total virtual bytes used by every process on a system under heavy load will add up to significantly more memory than the machine actually has.
There's another problem here; just as shared libraries can allocate memory inside your application module, leading to potential false positives reported in your app's Private Bytes, your application may also end up allocating memory inside the shared modules, leading to false negatives. That means it's actually possible for your application to have a memory leak that never manifests itself in the Private Bytes at all. Unlikely, but possible.
Private Bytes are a reasonable approximation of the amount of memory your executable is using and can be used to help narrow down a list of potential candidates for a memory leak; if you see the number growing and growing constantly and endlessly, you would want to check that process for a leak. This cannot, however, prove that there is or is not a leak.
One of the most effective tools for detecting/correcting memory leaks in Windows is actually Visual Studio (link goes to page on using VS for memory leaks, not the product page). Rational Purify is another possibility. Microsoft also has a more general best practices document on this subject. There are more tools listed in this previous question.
I hope this clears a few things up! Tracking down memory leaks is one of the most difficult things to do in debugging. Good luck.
Aaronaught
Aaronaught 116k●2424 gold badges●253253 silver badges●329329 bronze badges
I am afraid that you answer is not quite correct. Private Bytes refer to the amount of memory (RAM) that the process executable has asked for - not only physical memory. Thus you can surely inspect most of the memory leak cases by monitoring private bytes. Try ::VisualAlloc to commit a large chunk of memory (say 1.5G). You should be able to see that your private bytes are way larger than the working set. Which proves that your "Working Set is the Private Bytes plus Memory-mapped files" is incorrect. – Jay Zhu Apr 2 '10 at 9:46
Actually, I beleive the write understanding is "Working Set is the in-memory Private Bytes plus Memory-mapped files". And Private Bytes CAN be swapped out - you can see private bytes larger than the physical memory you have in the machine. – Jay Zhu Apr 2 '10 at 9:47
@Aaronaught: Your first statement about reliable indicator and appropriate for debugging is confusing. Private bytes is a reliable indicator of a leak the application memory space. It could be a dependent DLL and indirect but it is a leak in the application memory space. Can you explain why it cannot be used for debugging? a full memory dump of the application process should tell us what is consuming this memory. I am not sure i understand why it cannot be used for debugging. Can you shed some light? – G33kKahuna Jan 30 '12 at 13:57
@G33kKahuna: It's not clear to me how a memory dump would tell you what is consuming the memory in any meaningful sense - unless by "what" you mean "what modules", but then all you have is a snapshot, you still cannot see which module is actually leaking the memory over time unless you take several dumps over time and under tightly controlled conditions. It's hard to conceive of a more inefficient and unreliable debugging strategy. Profilers are everywhere these days; use one. – Aaronaught Jan 30 '12 at 15:58
Run a full !objsize, this should show any pinned objects in the immediate heap. You can confirm by checking the eeheap -gc. This should show you where the volume is stuck. Typically, if no hints are available with all of the above commands, your private bytes are consumed by uncollected objects in GC. Now move on to either gchandles or gcleaks. These commands should tell you what types/ object address cannot be mapped. The pointer is still there but object is gone. This is such categorical problem for unreleased event handlers. – G33kKahuna Feb 9 '12 at 15:52
You should not try to use perfmon, task manager or any tool like that to determine memory leaks. They are good for identifying trends, but not much else. The numbers they report in absolute terms are too vague and aggregated to be useful for a specific task such as memory leak detection.
A previous reply to this question has given a great explanation of what the various types are.
You ask about a tool recommendation: I recommend Memory Validator. Capable of monitoring applications that make billions of memory allocations.
Disclaimer: I designed Memory Validator.
Stephen Kellett
Stephen Kellett 2,765●11 gold badge●1919 silver badges●2525 bronze badges
I can't even run a simple class file (in Java)? What gives? – jn1kk Mar 6 '12 at 16:13
I suspect that Stephen and Devil are somehow related or even cloned... :D ;) – Robert Koritnik Apr 10 '12 at 13:36
@StephenKellett, Is there a trial version? – Pacerier Apr 12 '15 at 18:51
@Pacerier if you follow the link there is a trial for both the x86 and x64 versions just above the buy option on the left of the page. – Bradley A. Tetreault Apr 14 '15 at 23:43
The definition of the perfmon counters has been broken since the beginning and for some reason appears to be too hard to correct.
A good overview of Windows memory management is available in the video "Mysteries of Memory Management Revealed" on MSDN: It covers more topics than needed to track memory leaks (eg working set management) but gives enough detail in the relevant topics.
To give you a hint of the problem with the perfmon counter descriptions, here is the inside story about private bytes from "Private Bytes Performance Counter -- Beware!" on MSDN:
Q: When is a Private Byte not a Private Byte?
The Private Bytes counter reports the commit charge of the process. That is to say, the amount of space that has been allocated in the swap file to hold the contents of the private memory in the event that it is swapped out. Note: I'm avoiding the word "reserved" because of possible confusion with virtual memory in the reserved state which is not committed.
Private memory, is defined as memory allocated for a process which cannot be shared by other processes. This memory is more expensive than shared memory when multiple such processes execute on a machine. Private memory in (traditional) unmanaged dlls usually constitutes of C++ statics and is of the order of 5% of the total working set of the dll.
Mark
Mark 131●11 silver badge●22 bronze badges
riQQ
4,524●44 gold badges●2222 silver badges●3636 bronze badges
up vote because of the insanely good examples about how it's broken! – Bruno Brant Apr 24 '18 at 19:20
The first quote is mistaken. Allocating "Private bytes" doesn't require anything be "allocated in the swap file" (which is really called the pagefile). You don't even have to have a pagefile for "private bytes" to be allocated. In fact, allocating private bytes doesn't immediately use any space anywhere, and may not ever use as much as was allocated. – Jamie Hanrahan Nov 11 '18 at 4:44
The second quote isn't much better. Private bytes used in DLL code is not necessarily mostly statically allocated within the DLL. DLL code is perfectly free to call VirtualAlloc, HeapAlloc (malloc and new in the CRTL), etc. It also tries to describe private memory size as a percentage of working set size, which is nonsensical. The former is a virtual size (and will be the same for every use of the code with the same input) while the latter is physical (which can be radically different from one run to the next, depending on how much memory-rich or -starved the machine is). – Jamie Hanrahan Nov 11 '18 at 4:49
There is an interesting discussion here: http://social.msdn.microsoft.com/Forums/en-US/vcgeneral/thread/307d658a-f677-40f2-bdef-e6352b0bfe9e/ My understanding of this thread is that freeing small allocations are not reflected in Private Bytes or Working Set.
then the Private Bytes reflect only the allocation, not the deallocation.
then the Private Bytes correctly reflect the allocation and the deallocation.
mcanti
mcanti 1,904●22 gold badges●1616 silver badges●1414 bronze badges
This is explained by the fact that the C standard library memory functions use a custom or Win32 Heap which is a memory management mechanism on top of the low-level process-level memory management. – Kyberias Jun 1 '13 at 8:37
@Kyberias, So how do we get below that? – Pacerier Apr 11 '15 at 9:34
while(1) free(malloc(1000)); // Would this cause Private Bytes to increase forever ? – franckspike Jul 10 '15 at 15:09
@franckspike: no, it will increase to a certain point (generally about 4 kB, but this can vary) and then stop, because the CRT will re-use previously freed memory instead of requesting new pages from the OS. – Miral Jul 22 '15 at 0:04
@Pacerier: You can call VirtualAlloc and VirtualFree. – Jamie Hanrahan Nov 11 '18 at 4:53
Click here to upload your image (max 2 MiB)
You can also provide a link from the web.
By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy
2021 Stack Exchange, Inc. user contributions under cc by-sa
By clicking “Accept all cookies”, you agree Stack Exchange can store cookies on your device and disclose information in accordance with our Cookie Policy.
Accept all cookies Customize settings

Calculate Memory (Working Set - Private) Programmatically in Windows XP/2000
This will explain the overall process of how to get private working set memory of any process in Windows XP/2000
I have seen some questions related to this issue. In this article, I will focus on details of how to programmatically get Memory (Working Set - Private) of any running process in Windows.
First of all, you must know the difference between working set & private working set memory. Working set actually tells you how many virtual pages for the process are mapped into physical memory. Working set memory is the amount of memory in the private working set plus the amount of memory the process is using that can be shared by other running processes. So basically private working set is the subset of working set that specifically describes the amount of memory a process is using that cannot be shared by other processes.
If you notice the task manager in Vista & Windows 7, window shows Memory (Private Working Set) which is the key thing to consider in case of memory issues. But this thing was not popular\supported in Windows 2000 & XP. If you observe Windows XP’s task manager, it shows “Mem Usage” which is basically ‘Memory (Working Set)’ and this is sort of general memory for that specific process. Windows XP do not support\show private working set memory.
Usually, we use performance counters to monitor memory usage and yes there is a process object counter to get the private working set memory of any specific running process with the name “Working Set – Private” but this is not supported in Windows XP/2000 systems. If you try to use this in XP, it throws an exception.
According to MSDN, you can calculate this memory usage in XP using different things but MSDN provides very little information about this.
In the article, I will code the process of calculating memory (Working Set-Private) in Windows XP. You can also verify the memory count you are receiving is correct by running this solution on non XP systems and open the Windows task manager at the same time.
The key function to get this thing done is PSAPI function name QueryWorkingSet(). It gives you the working set information of a process and we can calculate private working set on the base of this.
In the implementation of CalculateWSPrivate() function, we are calculating the Working Set Private memory of any particular process whose process ID we will pass in this function. Outside of this function, we will declare a big array (dWorkingSetPages) which will receive the working set information return from QueryWorkingSet(). No worries, it will not affect the size of our current executable because this is not initialized one. We will also declare the page size (dPageSize) and readjust its value in the function.
In this method (CalculateWSPrivate), our key calling function is QueryWorkingSet(). QueryWorkingSet requires process handle which we can get by calling OpenProcess(). If QueryWorkingSet() succeed, this will return page count in the first entry of passed array. After that, we will iterate all subsequent pages that are contiguous in working set memory and have the same attribute (shared or private or from page table region). At the end, we will have the exact count of shared and private memory areas. So in this way, we can get the working set private memory (which is basically none shared memory) of the particular process. 
As you can see, I implemented this function in C++ Win32 DLL, you can easily utilize this in C# by using P/Invoke:
This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)
You must Sign In to use this message board.
Article Copyright 2010 by Najam ul Hassan
Everything else Copyright © CodeProject, 1999-2021

Web03 2.8.20210721.1


3d Shemale Tube
Www Xxx 720
Sex Na Mamu
Mature Web Ru
Free Tiny Private
Calculate Memory (Working Set - Private) Programmatically ...
A few words on memory usage or: working set vs. private ...
Working Set - Win32 apps | Microsoft Docs
Working Set Private (WorkingSetPrivate) - Docume…
Private Bytes VS Working Set in Process Explorer - Super User
Process Working Set - Win32 apps | Microsoft Docs
Private bytes, working set, virtual bytes. Обьясните пож
Working Set Private


Report Page