WHM/Cpanel 和 Linux 中内存使用的差异
如果我转到 WHM 并查看服务器的内存使用情况,它会显示只有 16% 的内存正在使用。 但是当我使用 SSH 连接到服务器并运行命令“free -m”时,它显示 80% 正在使用中。这是为什么?我想知道所有运行的应用程序(如 MySQL、Apache 等)的确切内存使用情况 我如何看待这一点?
谢谢
If I go to WHM and see my server's memory usage, it says that only 16% of memory is in use.
But when I connect to server using SSH and run command "free -m" then it shows that 80% is in use. Why is that? I want to know exact memory usage of all applications running like MySQL, Apache e.t.c.
How do I view that?
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如他们所说,“这很复杂”。
Linux 使用未使用的内存进行磁盘缓冲和缓存。它加快了速度。但您可能需要查看 free 的 -/+ buffers/cache 行。
'ps' 可以显示任何给定进程或所有进程的 %cpu、%mem ,累积CPU时间,rss(驻留集大小,非-进程正在使用的交换物理内存),大小(如果进程变脏,非常所需的交换空间量所有可写页面,然后被换出),vsize(整个进程的虚拟内存使用量(vm_lib + vm_exe + vm_data + vm_stack))等等。
对于任何给定的进程,您可以 cat /proc/$PID/status —— 它是人类可读的 —— 并检查 VmSize、VmLck , VmRSS, VmData, VmStk, < strong>VmExe、VmLib 和 VmPTE 值,以及与其他人...
但这只是对于初学者来说...进程可以分配内存但不能使用它。 (可以分配内存,但内存页面在实际使用之前不会创建/发布。整个按需的事情。)
进程可以在硬件空间中映射,显示为使用大量实际上并未到来的内存来自系统 RAM。 (众所周知,X 服务器有时会这样做。这是一些涉及内核驱动程序的奇怪的东西......)
有可执行文件,通常是内存映射文件。这意味着换入的部分会占用 RAM,但换出时不会占用交换文件空间。
进程可以有其他内存映射文件...
有共享内存库,其中多个程序同时使用相同的 RAM 页。
所以我们不得不问,就记忆而言,到底什么是重要的,什么是不重要的?
As they say, "It's Complicated".
Linux uses unused memory for disk buffering and caching. It speeds things up. But you may need to look at the -/+ buffers/cache line of free.
'ps' can show you, for any given process, or for all processes, the %cpu, %mem, cumulative cpu-time, rss (resident set size, the non-swapped physical memory that a process is using), size (very approximate amount of swap space that would be required if the process were to dirty all writable pages and then be swapped out), vsize (virtual memory usage of entire process (vm_lib + vm_exe + vm_data + vm_stack)), and much much more.
For any given process, you can cat /proc/$PID/status -- it's human readable -- and check out the VmSize, VmLck, VmRSS, VmData, VmStk, VmExe, VmLib, and VmPTE values, along with others...
But that's just for starters... Processes can allocate memory but not use it. (Memory can be allocated, but the memory pages are not created/issued until they're actually used. That whole on-demand thing.)
Processes can map in hardware space, showing up as using a large quantity of memory that's not actually coming from system RAM. (X-servers are known to sometimes do this. It's some wonky stuff involved kernel drivers...)
There's the executable, which is usually a memory-mapped file. Meaning that parts that are swapped-in are taking up RAM, but when swapped out it never takes up swapfile space.
Processes can have other memory-mapped files...
There's shared-memory libraries, where the same RAM pages are used by multiple programs concurrently.
So we have to ask, as far as memory goes, what exactly counts and what doesn't?