Why does `/proc/meminfo` show 32GB when AWS instance has only 16GB?

后端 未结 1 586
南旧
南旧 2020-12-19 21:39

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

相关标签:
1条回答
  • 2020-12-19 22:00

    I wanted to log the size of the currently running instance

    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

    Please define what is used memory.

    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 ?

    Then, read documentation related to proc(5).

    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/

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

    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.

    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.

    0 讨论(0)
提交回复
热议问题