如何查看Linux对RAM的看法以便确定碎片 [英] How to see Linux' view of the RAM in order to determinate the fragmentation

查看:164
本文介绍了如何查看Linux对RAM的看法以便确定碎片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我所知道的唯一与之相关的程序是pmap,但这只会打印一个进程的内存.

The only program relevant I know of is pmap, but this only prints the memory of one process.

我想看看物理内存是如何被占用的,以及整个物理RAM的哪个进程/库(包括内核)(与带有).

I would like to see how the physical memory is occupied and by which processes/library, including the kernel, of the entire physical RAM (as opposed to that from the process' POV with pmap).

理想情况下还具有图形界面.

Ideally also with a graphical interface.

您知道是否有这样的工具吗?

Do you know if there's any such tool?

我知道图书馆引入的歧义.如果是这种情况,它可能会显示一条1像素宽的线和一个指向该库实际位置的箭头.

I know about the ambiguity introduced by libraries. If it's the case, it could display a 1-pixel wide line and an arrow to the real location of that library.

我需要什么?要查看RAM碎片.

What do I need this for? To view the RAM fragmentation.

推荐答案

内存碎片

Linux系统运行一段时间后,内存碎片会增加,这在很大程度上取决于在其上运行的应用程序的性质.分配和释放内存的进程越多,内存碎片就越快.而且内核可能无法始终对所需的大小按时对足够的内存进行碎片整理.如果发生这种情况,即使有足够的可用内存,应用程序也可能无法分配更大的连续内存块.从2.6内核(即RHEL4和SLES9)开始,内存管理得到了极大的改善,内存碎片也不再是问题.

Memory Fragmentation

When a Linux system has been running for a while memory fragmentation can increase which depends heavily on the nature of the applications that are running on it. The more processes allocate and free memory, the quicker memory becomes fragmented. And the kernel may not always be able to defragment enough memory for a requested size on time. If that happens, applications may not be able to allocate larger contiguous chunks of memory even though there is enough free memory available. Starting with the 2.6 kernel, i.e. RHEL4 and SLES9, memory management has improved tremendously and memory fragmentation has become less of an issue.

要查看内存碎片,可以使用魔术的SysRq键.只需执行以下命令:

To see memory fragmentation you can use the magic SysRq key. Simply execute the following command:

# echo m > /proc/sysrq-trigger

此命令会将当前内存信息转储到/var/log/messages.这是RHEL3 32位系统的示例:

This command will dump current memory information to /var/log/messages. Here is an example of a RHEL3 32-bit system:

Jul 23 20:19:30 localhost kernel: 0*4kB 0*8kB 0*16kB 1*32kB 0*64kB 1*128kB 1*256kB 1*512kB 1*1024kB 0*2048kB 0*4096kB = 1952kB)
Jul 23 20:19:30 localhost kernel: 1395*4kB 355*8kB 209*16kB 15*32kB 0*64kB 0*128kB 0*256kB 0*512kB 0*1024kB 0*2048kB 0*4096kB = 12244kB)
Jul 23 20:19:31 localhost kernel: 1479*4kB 673*8kB 205*16kB 73*32kB 21*64kB 847*128kB 473*256kB 92*512kB 164*1024kB 64*2048kB 28*4096kB = 708564kB)

第一行显示DMA内存碎片.第二行显示低内存碎片,第三行显示高内存碎片.输出显示内存不足"区域中的内存碎片.但是在High Memory区域中有许多大的内存块可用,例如28 4MB.

The first line shows DMA memory fragmentation. The second line shows Low Memory fragmentation and the third line shows High Memory fragmentation. The output shows memory fragmentation in the Low Memory area. But there are many large memory chunks available in the High Memory area, e.g. 28 4MB.

如果内存信息未转储到/var/log/messages,则未启用SysRq.您可以通过将sysrq设置为1来启用SysRq:

If memory information was not dumped to /var/log/messages, then SysRq was not enabled. You can enable SysRq by setting sysrq to 1:

# echo 1 > /proc/sys/kernel/sysrq

从2.6内核(即RHEL4和SLES9)开始,您不需要SysRq来转储内存信息.您只需检查/proc/buddyinfo的内存碎片即可.

Starting with the 2.6 kernel, i.e. RHEL4 and SLES9, you don’t need SysRq to dump memory information. You can simply check /proc/buddyinfo for memory fragmentation.

这是运行2.6内核的64位服务器的输出:

Here is the output of a 64-bit server running the 2.6 kernel:

# cat /proc/buddyinfo

Node 0, zone DMA 5 4 3 4 3 2 1 0 1 1 2
Node 0, zone Normal 1046 527 128 36 17 5 26 40 13 16 94
# echo m > /proc/sysrq-trigger
# grep Normal /var/log/messages | tail -1
Jul 23 21:42:26 localhost kernel: Normal: 1046*4kB 529*8kB 129*16kB 36*32kB 17*64kB 5*128kB 26*256kB 40*512kB 13*1024kB 16*2048kB 94*4096kB = 471600kB
#

在此示例中,我再次使用SysRq来显示/proc/buddyinfo中的每个数字所指的含义.

In this example I used SysRq again to show what each number in /proc/buddyinfo is referring to.

来源: http://www.puschitz.com/pblog/

这篇关于如何查看Linux对RAM的看法以便确定碎片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆