Linux 什么是活动内存和非活动内存

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/18529723/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-07 00:42:46  来源:igfitidea点击:

What is active memory and inactive memory

linux

提问by user2714918

What is active memory and inactive memory? I am executing the command vmstat -aon a Linux machine and I am getting the following output:

什么是活动内存和非活动内存?我vmstat -a在 Linux 机器上执行命令,得到以下输出:

vmstat -a
procs -----------memory---------- ---swap-- -----io---- --system-- -----cpu------
 r  b   swpd   free  inact active   si   so    bi    bo   in   cs us sy id wa st
 1  0 249900 4801880 2649428 8246152    0    0    42    31    0    0  4  0 95  0  0

But I am not getting what exactly active and inactive memory is... Could you please elaborate?

但我不明白活动和非活动内存究竟是什么......你能详细说明一下吗?

回答by Gangadhar

There are two states of "used" memory, "inactive" and "active".

“已用”内存有两种状态,“非活动”和“活动”。

Active memoryis memory that is being used by a particular process.
Inactive memoryis memory that was allocated to a process that is no longer running.are pages which have not been accessed "recently"

活动内存是特定进程正在使用的内存。
非活动内存是分配给不再运行的进程的内存。是“最近”未访问过的页面

to see the memory use /proc/meminforather than vmstat -a

查看内存使用/proc/meminfo而不是vmstat -a

cat /proc/meminfo  

you need not to clear this Inactive memory When system reboots this memory automatically became vanish, still If you have a large amount of inactive memory ,you can use following command.

你不需要清除这个非活动内存当系统重新启动时,这个内存会自动消失,如果你有大量的非活动内存,你可以使用以下命令。

free && sync && echo 3 > /proc/sys/vm/drop_caches && echo "" && free
free && sync && echo 3 > /proc/sys/vm/drop_caches && echo "" && free

EditAs per @kubanczyk comment: you can find more information from this question

根据@kubanczyk 评论编辑:您可以从这个问题中找到更多信息