• 1382721 Linux: Interpreting the output of the command 'free'


    Symptom

    The Linux command 'free' indicates a very high memory consumption.

    Other Terms

    Free, Linux, memory consumption

    Reason and Prerequisites

    The memory requirement of your SAP system (that you determine using transaction ST02, for example) does not correspond to the memory consumption values that are displayed by the Linux command 'free'.

    Solution

    The following is an example of an output of the Linux command 'free -m' (the option -m ensures that the output is in megabytes):

                total     used     free  shared  buffers  cached
    Mem:          7748    7543      205      0      55     4935
    -/+ buffers/cache:     2553    5195
    Swap:        16383      62    16321

    A total of 7748 MB of main memory is available for this sample system. According to the display, 7543 MB of this total are used, and 205 MB are free.
    However, in addition to this, memory that is considered as part of the 'cached' area can, if required, be made available for the applications (such as the Page Cache) again by the Linux kernel so that, in principle, more memory is "free".
    This assumption is also supported by the 'free' value minus the 'buffers' and 'caches' in the second line of 5195 MB.

    Unfortunately, the 'cached' area cannot be considered as completely 'free' because, among other things, the following memory areas are also considered to be 'cached':

    • The page cache of the Linux kernel
    • SAP Shared Memory areas, such as the SAP buffer and the extended memory
    • Shared Memory areas of the database, such as the database cache

    While the page cache, for example, is available for applications if required, the database and the SAP areas are occupied by the relevant applications and cannot be released without further action.
    For this reason, you must not pay attention to only the value of the free memory ('free') in the first line (205 MB) or in the second line (5195 MB) when the system outputs the Linux command 'free'. (The value of 5195 MB is calculated as follows: 205 ("free") MB + 55 ("buffers") MB + 4935 ("cached") MB.)
    Therefore, the actual "free" memory that is available for other memory requests ranges between the two values, which is why the Linux command 'free' cannot be used to determine the exact memory that is currently free.

    The current version of the Linux kernel offers the option to use '/proc/meminfo' to additionally read the value for "Shmem" that specifies how much shared memory is currently used in the system.
    To determine the current size of the Linux page cache, you can roughly use the following calculation in this case:
    Linux page cache = cached - Shmem

    For example, as follows:

    # egrep "^Cached|Shmem" /proc/meminfo
    Cached:          4924772 kB
    Shmem:           3720776 kB

    This means that currently, 1175 MB of page cache are used that are generally available to other applications if required.
    Note that the value that you calculated this way (1175 MB) deviates significantly from the above-stated 5195 MB, especially in SAP environments, for the stated reasons.

  • 相关阅读:
    Docker常用命令
    CentOS7.8源码安装nginx
    CentOS7.8搭建STF
    Mac关闭系统安全保护(提示无权删除/usr/bin目录下的文件时)
    Mac本地安装Tcloud-后端
    Mac后台运行进程-终端退出不影响其后台运行
    Docker快速部署TCloud云测试平台--前端
    Docker快速部署TCloud云测试平台--后端
    【项目】项目组件索引
    Netty 直接内存(堆外内存)溢出分析
  • 原文地址:https://www.cnblogs.com/weikui/p/16135035.html
Copyright © 2020-2023  润新知