V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
Tidycc
V2EX  ›  Linux

Linux 小白,请教下 Linux 内存占用的问题。

  •  
  •   Tidycc · 2018-11-19 20:41:49 +08:00 · 2343 次点击
    这是一个创建于 1956 天前的主题,其中的信息可能已经有所发展或是发生改变。

    系统环境: 服务器上的虚拟机,虚拟机配置如下:

    问题如下:

    长期不关机的时候存在内存占用很高的情况,没有打开任何应用的情况下也是占用很高,这是长时间不关机的情况:

    刚重启的情况:

    请问这种情况的原理是什么?是内存泄漏吗?该怎么解决呢? 谢谢大家的回答-----------

    7 条回复    2018-11-21 13:33:46 +08:00
    Nimrod
        1
    Nimrod  
       2018-11-19 20:44:09 +08:00 via Android
    是不是什么自启软件有内存泄露啊…
    fonlan
        2
    fonlan  
       2018-11-19 21:16:44 +08:00 via Android
    htop 看下内存占用最大的是哪个进程啊,标准操作吧
    q397064399
        3
    q397064399  
       2018-11-19 21:26:58 +08:00
    这种问题还是上 stackoverflow 太多了
    srx1982
        4
    srx1982  
       2018-11-19 21:27:16 +08:00
    把 htop 下边的进程也截图出来就知道了
    cdzone
        5
    cdzone  
       2018-11-19 21:28:33 +08:00
    应该是 cache 吧,free 看看 buffer cache 和 available 占多少。如果不是那得看看是什么进程占用的了。btw,现在 PC 都这么大内存了么? 32G 啊。。。前两年公司发给我的电脑还是 8G 的
    jasonyang9
        6
    jasonyang9  
       2018-11-19 21:40:18 +08:00
    赞同 5 楼,没有 swap 是 OK 的。`vmstat`看下也可以。

    To reduce costs of accessing persistent storage, most systems use aggressive caching subsystems to keep popular data in memory. Linux, in this regard, is no different than traditional operating systems.

    The Linux page cache is unified, keeping pages in memory from three primary sources: memory-mapped files, file data and metadata from devices (usually accessed by directly `read()` and `write()` calls to the file system), and heap and stack pages that comprise each process (sometimes called anonymous memory, because there is no named file underneath of it, but rather swap space). These entities are kept in a page cache hash table, allowing for quick lookup when said data is needed.

    blah blah...
    getecho
        7
    getecho  
       2018-11-21 13:33:46 +08:00
    top 按 M 看进程内存使用情况排序。看占用大的内存的进程名是什么。如果是系统服务就去查系统服务是不是有内存泄漏之内的 bug,不过几率比较低。如果是自己的服务,那就再具体分析。
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   1551 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 17:12 · PVG 01:12 · LAX 10:12 · JFK 13:12
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.