Encounter "thrashing"

Source: Internet
Author: User
Tags high cpu usage

Thrashing's Chinese translation is called "Bumpy". It sounds strange to hear it. In fact, many technical terms are not easy to say.

This is the case. When your physical memory is insufficient, you need to write the amount of space from the memory to the pagefile first for every amount of content read from the pagefile. This read/write operation will make your system very angry. If the physical memory is not released for a long time, all operations involving page fault will go through this read/write operation, the final result is that each step is as slow as a snail bait.

In fact, the system is already in a very unstable state, learning the name "Thrashing ".

Thrashing has been used in university Operating System courses and has been used in performance-related books or articles. However, it is really hard to say that Thrashing has never been used. I think there are two reasons: one is that the current hardware is so cheap, and the memory is generally enough; the other is that I am not the kind of person who will open countless programs at the same time, even if the system is slow sometimes, it will be quickly turned off to avoid thrashing.

However, today, I was on a dual-core 4G memory computer and felt like a system "Bumpy ~~~

Symptom

I used the ProcMon tool to observe the behavior of the program after adding my code. After I thought it was okay, I planned to perform full build locally, so I started the IncrediBuild and built it, at the same time, I also switched to another machine to continue working-our code, a full build, is not 4 hours at all.

Several hours later, I went back to the computer to check the situation: the tragedy happened, the mouse crossed the screen at an extremely slow speed, and clicked the IncrediBuild icon on the taskbar, it is also delayed. Next, all my operations are performed at the "16X slow forward" speed ~~~

 

Guess

The first suspect is of course the IncrediBuild, because it is mainly doing things. Open procexp and check that there are no processes with high CPU usage. I know that IncrediBuild has many disk operations, but its disk operations do not affect the system to this point ~~~

Press Ctrl + I to open the procexp system information dialog box and check that the physical memory usage is close to 4 GB. At this point, I understand that thrashing has never been encountered for me for a hundred years. However, in just a few hours, the physical memory usage soared to 4 GB. Is there any memory leakage in IncrediBuild? This is a big leak. Do not say it is impossible. Even so, these leaks will be exchanged to pagefile after they are used for a period of time, instead of filling up the physical memory, windows Memory Manager is not so stupid.

 

Analysis

Then, I see the following information in the system information box:

Why does the value of Commit Charge reach 16 GB (pagefile + memory )? Generally, there is only 3G, 5G. In this process, I didn't open any new programs. Even if all the private bytes of all the originally opened programs are written to pagefile, there won't be so many, what's more, physical memory is also running at full capacity.

Obviously, someone is playing tricks and constantly writing data to pagefile. Think about it in detail: ProcMon! It is found that by default, it will write the event information it captures to pagefile:

 

So far, we can infer what happened:

  1. ProcMon constantly writes data to pagefile, and the data volume is huge.
  2. The size of pagefile is constantly adjusted until the limit is reached = 4G * 3. (See Pushing the Limits of Windows: Virtual Memory)
    On Windows Vista and Server 2008, the minimum is intended to be large enough to hold a kernel-memory crash dump and is RAM plus 300 MB or 1 GB, whichever is larger. the maximum is either Three times the size of RAM or 4 GB, Whichever is larger.

  3. Then, the physical memory is constantly pushed up for the following reasons:
  • ProcMon tries to continue writing data to pagefile, but the pagefile is full, so as if the memory is full, it will write to pagefile. If the pagefile is full, it will also be transferred to the memory. Therefore, the memory is also full.
  • Alternatively, when pagefile is fully written, IncrediBuild cannot swap the memory it uses to pagefile, resulting in increasing physical memory until it is fully written.
  • Physical memory is at full load and starts to experience bumps ~~~
  • Conclusion

    You must be careful when using a program such as ProcMon that will endlessly write things to the pagefile, and close it in time (when it occupies the Commit Charge, it will be released immediately) or set it to write it to an independent file.

    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.