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

2018-11-19 20:41:49 +08:00
 Tidycc

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

问题如下:

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

刚重启的情况:

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

2381 次点击
所在节点    Linux
7 条回复
Nimrod
2018-11-19 20:44:09 +08:00
是不是什么自启软件有内存泄露啊…
fonlan
2018-11-19 21:16:44 +08:00
htop 看下内存占用最大的是哪个进程啊,标准操作吧
q397064399
2018-11-19 21:26:58 +08:00
这种问题还是上 stackoverflow 太多了
srx1982
2018-11-19 21:27:16 +08:00
把 htop 下边的进程也截图出来就知道了
cdzone
2018-11-19 21:28:33 +08:00
应该是 cache 吧,free 看看 buffer cache 和 available 占多少。如果不是那得看看是什么进程占用的了。btw,现在 PC 都这么大内存了么? 32G 啊。。。前两年公司发给我的电脑还是 8G 的
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
2018-11-21 13:33:46 +08:00
top 按 M 看进程内存使用情况排序。看占用大的内存的进程名是什么。如果是系统服务就去查系统服务是不是有内存泄漏之内的 bug,不过几率比较低。如果是自己的服务,那就再具体分析。

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/509400

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX