为什么当AWS实例只有16GB时`/proc/meminfo`会显示32GB? [英] Why does `/proc/meminfo` show 32GB when AWS instance has only 16GB?

查看:87
本文介绍了为什么当AWS实例只有16GB时`/proc/meminfo`会显示32GB?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想记录当前正在运行的实例的内存总量(或者:当前进程使用的内存和当前进程可用的内存),并使用/proc/meminfo:

I wanted to log the total amount of memory (alternatively: used memory by the current process and available memory for the current process) of the currently running instance and used /proc/meminfo:

info = {
    i.split()[0].rstrip(":"): int(i.split()[1])
    for i in open("/proc/meminfo").readlines()
}
total_m = info["MemTotal"]

当我在本地运行它时,它可以完成我期望的工作.当我在Docker容器中的16GB AWS实例上运行它时,它显示为32GB.为什么会这样呢?

When I run it locally, it does what I expect. When I run it on a 16GB AWS instance in a Docker container it shows 32GB. Why is that the case?

(侧面问题:该怎么做?)

(Side question: How should this be done?)

推荐答案

我想记录当前正在运行的实例的大小

I wanted to log the size of the currently running instance

您没有为您定义什么实例. AFAIK在AWS和Docker中具有不同的含义.

You don't define what is an instance for you. AFAIK it has a different meaning in AWS and in Docker.

当前进程使用的内存

used memory by the current process

请定义已使用的内存.

详细了解虚拟地址空间. 页面缓存该怎么办?

Read much more about virtual address space. What about the page cache ?

当前进程的可用内存

available memory for the current process

请定义可用内存.您是否知道分页? 共享库呢?

Please define what is available memory. Are you aware of paging ? What about shared libraries ?

然后,阅读与 proc(5).

您真的应该关心当前的流程,而不是整个系统.阅读优质的操作系统教科书和 https://www.linuxatemyram.com/

You really should care about the current process, not the entire system. Read a good operating system textbook and the Advanced Linux Programming book, and https://www.linuxatemyram.com/

如果您关心当前过程,请使用 proc(5) /proc/self/stat

If you care about the current process, use proc(5) thru /proc/self/stat

如果您关心自己的AWS实例,则可以使用一些专有的API查询其状态.

If you care about your AWS instances, there are some proprietary APIs for querying their status.

如果要自动执行某些系统管理任务,则应说明哪些任务以及原因.

If you are automatizing some system administration tasks, you should explain which ones and why.

请注意,/proc/meminfo提供了系统范围的信息并与虚拟内存相关. AWS 添加了管理程序层, Docker a>,您可以在某个虚拟级别上进行一些流程迁移.

Notice that /proc/meminfo gives system-wide information and relates to virtual memory. AWS is adding hypervisor layers and so does Docker and you could have some process migration at some virtual level.

这篇关于为什么当AWS实例只有16GB时`/proc/meminfo`会显示32GB?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆