Windows Memory knowledge points

Source: Internet
Author: User

I used to write an articleArticleThe difference between Task Manager and Performance Monitor (Working Set and private bytes) is not clear about Windows Memory.

I 've recently heard about Mark russinovich's Windows Memory lecture from start to end, so I recorded my notes here.

 

Memory Basics

======================================

The memory address is divided into three parts:

    • Private-Example: Process heap
      • Reserved or committed
    • Resumable-Example: EXE, DLL, shared memory, other memory mapped Files
      • Reserved or committed
    • Free

 

In performance monitor, there are the following counters.

    • Private bytes-committed private memory
    • Virtual bytes-total of bytes able + private (including reserved)

There is no separate counter for retriable, reserved, or free memory.

 

What is the difference between committed and reserved?

======================================

For example, we need eight people to have dinner together, but these eight people cannot arrive at the hotel at the same time. therefore, we need to order an eight-person table. the booked eight-person table is reserved, but the person who goes first and sits down is committed.

The stack in the process is a typical application of this concept. The call stack must be continuous, but it is not full at a time.ProgramIn-depth call, the space of the Reserve stack will be commit a little bit.

 

Take Manager

======================================

The following items are displayed in task manager.

The default memory-private working set has nothing to do with virtual memory, because the working set trimming, this column does not reflect the impact of the process on the memory of the entire system. In fact, it is useless.

Among them, memory-commit size and private byte are equal. Before Vista, this column is called VM Size. Vista and later it is called commit size.

Most memory problems have been caused by the leakage of private committed memory by processes, such as heap and GC heap.

However, the private byte counter does not disclose all the memory information, such as the shared memory applied for by memory fragments or DLL loaded only by the current process.

 

To view more memory information, you can use a tool called vmmap in sysinternal.

The image, mapped file, and retriable in the figure can be shared with other processes. The following are private.

 

What is a working set?

==================================

The process starts from an empty working set.

Page fault occurs when the process tries to access the memory page, because the page is not in the working set.

When the memory is sufficient, the process working set represents all the memory referenced by the process (not released yet ).

When the memory is insufficient, the working set will be compressed.

When memory manager thinks the process is large enough, some memory pages of the process will be discarded to free up space for new pages.AlgorithmSimilar to "queue first-in-first-out" and "last access elimination ".

The working set contains two types of pages.

    • Retriable
    • Private

Performance Counter has the following three counters to display the information.

    • Working Set retriable
    • Working Set private
    • Working set size (sum of the two above)

Some important points are that the working set will be trim out when the memory is insufficient, so sometimes it cannot be reversed to the memory hunger of the process.

 

Check reliable data sources for memory problems

==============================

Virtual size, private bytes, and working set in process explorer.

For example, sysinternal has a tool named testlimit, which is used to test the memory.

The test command is as follows:

· Testlimit-r 1024-C 1

    • O reserve 1 GB memory

· Testlimit-M 1024-C 1

    • O commit 1 GB memory, but do not access the memory.

· Testlimit-d 1024-C 1

    • O commit 1 GB memory and access these memories.

 

The following information can be seen in task manager. It can be seen that the three cannot be well distinguished.

The following information is displayed in process explorer.

 

Data Source

============================

Mysteries of Windows Memory Management revealed with Mark russinovich, part 2

Http://channel9.msdn.com/Events/TechEd/Europe/2010/WCL402

Mysteries of Windows Memory Management revealed with Mark russinovich, part 1

Http://channel9.msdn.com/Events/TechEd/Europe/2010/WCL401

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.