内存管理 - Linux 内存占用总是很高为何依旧很流畅?
阿神
阿神 2017-04-17 12:01:47
0
11
1136

Linux 的内存显示经常会出现 90% 多已被使用,但系统依旧很流畅的情况,想知道:

  1. 有时候 CPU 占用率很低,但内存占用率很高,内存都被怎么用掉了?
  2. 系统依旧流畅,不会像 Windows 卡成翔,原理在哪里?
阿神
阿神

闭关修行中......

reply all(11)
小葫芦

Regarding the first question, you can look at this SF answer, it should be very clear. Simply put, the memory is not actually used, but is cached by the system and can be released for use at any time.

Regarding the second question, the simple answer is that the programs under Linux are relatively ethical, and no one uses programs without ethics. If there weren't so many XX guards or XX assistants in Windows, just a bare operating system plus some necessary programs, and using SSD, there wouldn't be any lag.

阿神

Who said Windows would freeze? I use Windows in a virtual machine, and the memory, CPU, and video memory are very tight. The memory can only be allocated to 4G, the CPU can only be allocated to two cores and four threads, and the video memory can only be allocated to 768M. When I open Chrone to play 3D games, I never feel stuck (I used to) That game filled up the 2G memory of my old computer, and then it ran out of memory and crashed)

The reason why the memory occupied by the card is that it is forced to use virtual memory, that is, to exchange space with the hard disk. The hard disk will continue IO and freeze you.

It does not mean that high memory usage will definitely lead to lag. As long as the virtual memory is not used, for example, the occupied space is reclaimed immediately, there will be no lag.

Even if you use virtual memory and your hard drive is fast enough, there will be no problem. PCIe SSD try?

Look at iOS, there is no virtual memory at all, physical memory is 1G, is it stuck? It’s just that I often lose web pages I’ve seen before and have to reload them.


In addition, the reason why Ka Chengxiang installed XX Guard is that XX Guard inline hooked the key function of the system, KiFastCallEntry. This function is so critical that the response speed of XX Guard has become the upper limit of the system response speed. It is said that some software that only takes a few minutes to install can take up to several hours after Hooking KiFastCallEntry!

This is also the reason why XX does not perfectly support Win7 x64 - PatchGuard makes it difficult for XX to be as lawless as before.

大家讲道理

If you use a command line system to run services compared to a desktop system, it is obviously unfair
If you look at the smoothness of the ubuntu desktop, and then look at the smoothness of the windows desktop, let’s talk about the following topics

黄舟

Linux will borrow free memory as a disk cache. Disk data caching will make Linux run faster. It will never take out memory from the program. It has no disadvantages, but it will confuse novices. If your application When programs need more memory, they will reclaim part of the physical memory used for disk data caching and return it to the application. This process does not require initiating swapping. Disk caching cannot be disabled

Give a simple example

If you really want to compare it with Windows, the remaining memory size is +buffers/cache = 685544kb (about 680m)
The memory size used by the program is about 330m

Instead of using 900M, the remaining 100M

73m in buffer is used as block device for caching (recording file system metadata and tracking in flight pages)
510m in cache is used as cache file

Buffer and cache can make space for the program to use at any time

Hope it can be adopted~~

洪涛

Note: This answer is 50% relevant to the question. I just want to correct the name of Windows!


Who says Windows is stuck and who am I to worry about?

i3 mobile low-voltage version + 4G memory + SSD There are pictures to prove it:

Running win8.1 without any lag at all. Some people may ask, how many procedures have you opened?
Normally, my taskbar looks like this:

PHPStorm and Chrome are both big memory users. Except for PHPStorm which gets stuck a little bit when creating a new project index file, there are usually no unusual lags and the use is extremely smooth. If you have various online video playback clients and various so-called security and anti-virus processes in your process, it would be strange if it does not freeze!

I have always thought that Windows is for scientists and Mac OS X is for artists. I thought that I didn’t have enough artistic skills and couldn’t control the Linux desktop (I struggled with the Linux desktop distribution for a year and then returned it), so I still chose Windows. But if anyone says that Windows is stuck, I will still be anxious. Damn it, you installed a lot of rogue software and you blame Windows for being stuck. What do you want me to do?

大家讲道理

Memory is originally for human use. Memory can be recycled and regenerated. Why not use it?
They were all corrupted by the cleaning software on Windows. We must pursue low memory usage

阿神

In Linux, although you see a large memory footprint, a large part of it is actually cache. You can use

free -m

View actual memory usage.

巴扎黑

Under Linux, memory is cached, instead of being occupied by programs like under win

迷茫

The memory management of

linux is different. It will put some things that the user is expected to use in the memory to improve the reading speed. However, if the user needs the occupied memory, it will be given priority to the user. . .

刘奇

I never use this guard or that assistant, I only use mse and a lightweight anti-virus engine. No lag even without ssd.
The reason for the lag is that as soon as those rogue software are launched, they want all their descendants to come into battle and occupy the backend. The same is true for Android.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!