进程内存分配和/proc/xxx/maps简单分析

参考:http://blog.163.com/tao198352__4232/blog/static/8502064520105611157897/

    :http://blog.chinaunix.net/uid-9543173-id-3571436.html


下面是一个Linux进程的标准的内存段布局:

maps文件内容输出:

[root@NGFW src]# cat -n /proc/10800/maps
     1  00400000-0040a000 r-xp 00000000 08:01 156019                             /secgate/bin/ddns
     2  00609000-0060a000 rw-p 00009000 08:01 156019                             /secgate/bin/ddns
     3  025e9000-0260a000 rw-p 00000000 00:00 0                                  [heap]
     4  7f3958000000-7f3958021000 rw-p 00000000 00:00 0
     5  7f3958021000-7f395c000000 ---p 00000000 00:00 0
     6  7f395c000000-7f395c021000 rw-p 00000000 00:00 0
     7  7f395c021000-7f3960000000 ---p 00000000 00:00 0
     8  7f3960000000-7f3960021000 rw-p 00000000 00:00 0
     9  7f3960021000-7f3964000000 ---p 00000000 00:00 0
    10  7f39643b8000-7f39643b9000 ---p 00000000 00:00 0
    11  7f39643b9000-7f3964db9000 rw-p 00000000 00:00 0
    12  7f3964db9000-7f3964dba000 ---p 00000000 00:00 0
    13  7f3964dba000-7f39657ba000 rw-p 00000000 00:00 0
    14  7f39657ba000-7f39657d0000 r-xp 00000000 08:01 114924                     /lib64/libresolv-2.12.so
    15  7f39657d0000-7f39659d0000 ---p 00016000 08:01 114924                     /lib64/libresolv-2.12.so
    16  7f39659d0000-7f39659d1000 r--p 00016000 08:01 114924                     /lib64/libresolv-2.12.so
    17  7f39659d1000-7f39659d2000 rw-p 00017000 08:01 114924                     /lib64/libresolv-2.12.so
    18  7f39659d2000-7f39659d4000 rw-p 00000000 00:00 0
    19  7f39659d4000-7f39659d9000 r-xp 00000000 08:01 114961                     /lib64/libnss_dns-2.12.so
    20  7f39659d9000-7f3965bd8000 ---p 00005000 08:01 114961                     /lib64/libnss_dns-2.12.so
    21  7f3965bd8000-7f3965bd9000 r--p 00004000 08:01 114961                     /lib64/libnss_dns-2.12.so
    22  7f3965bd9000-7f3965bda000 rw-p 00005000 08:01 114961                     /lib64/libnss_dns-2.12.so
    23  7f3965bda000-7f3965be6000 r-xp 00000000 08:01 114980                     /lib64/libnss_files-2.12.so
    24  7f3965be6000-7f3965de6000 ---p 0000c000 08:01 114980                     /lib64/libnss_files-2.12.so
    25  7f3965de6000-7f3965de7000 r--p 0000c000 08:01 114980                     /lib64/libnss_files-2.12.so
    26  7f3965de7000-7f3965de8000 rw-p 0000d000 08:01 114980                     /lib64/libnss_files-2.12.so
    27  7f3965df1000-7f3965df2000 ---p 00000000 00:00 0
    28  7f3965df2000-7f39667f2000 rw-p 00000000 00:00 0
    29  7f39667f2000-7f396c683000 r--p 00000000 08:01 1679546                    /usr/lib/locale/locale-archive
    30  7f396c683000-7f396da94000 rw-s 00000000 00:10 45305                      /dev/shm/sg_dbg_ring
    31  7f396da94000-7f396daaa000 r-xp 00000000 08:01 114911                     /lib64/libgcc_s-4.4.6-20110824.so.1
    32  7f396daaa000-7f396dca9000 ---p 00016000 08:01 114911                     /lib64/libgcc_s-4.4.6-20110824.so.1
    33  7f396dca9000-7f396dcaa000 rw-p 00015000 08:01 114911                     /lib64/libgcc_s-4.4.6-20110824.so.1
    34  7f396dcaa000-7f396dd92000 r-xp 00000000 08:01 1663052                    /usr/lib64/libstdc++.so.6.0.13
    35  7f396dd92000-7f396df92000 ---p 000e8000 08:01 1663052                    /usr/lib64/libstdc++.so.6.0.13
    36  7f396df92000-7f396df99000 r--p 000e8000 08:01 1663052                    /usr/lib64/libstdc++.so.6.0.13
    37  7f396df99000-7f396df9b000 rw-p 000ef000 08:01 1663052                    /usr/lib64/libstdc++.so.6.0.13
    38  7f396df9b000-7f396dfb0000 rw-p 00000000 00:00 0
    39  7f396dfb0000-7f396dfb2000 r-xp 00000000 08:01 114857                     /lib64/libdl-2.12.so
    40  7f396dfb2000-7f396e1b2000 ---p 00002000 08:01 114857                     /lib64/libdl-2.12.so
    41  7f396e1b2000-7f396e1b3000 r--p 00002000 08:01 114857                     /lib64/libdl-2.12.so
    42  7f396e1b3000-7f396e1b4000 rw-p 00003000 08:01 114857                     /lib64/libdl-2.12.so
    43  7f396e1b4000-7f396e237000 r-xp 00000000 08:01 114704                     /lib64/libm-2.12.so
    44  7f396e237000-7f396e436000 ---p 00083000 08:01 114704                     /lib64/libm-2.12.so
    45  7f396e436000-7f396e437000 r--p 00082000 08:01 114704                     /lib64/libm-2.12.so
    46  7f396e437000-7f396e438000 rw-p 00083000 08:01 114704                     /lib64/libm-2.12.so
    47  7f396e438000-7f396e586000 r-xp 00000000 08:01 155978                     /secgate/lib/libxml2.so
    48  7f396e586000-7f396e785000 ---p 0014e000 08:01 155978                     /secgate/lib/libxml2.so
    49  7f396e785000-7f396e791000 rw-p 0014d000 08:01 155978                     /secgate/lib/libxml2.so
    50  7f396e791000-7f396e792000 rw-p 00000000 00:00 0
    51  7f396e792000-7f396e7c4000 r-xp 00000000 08:01 155979                     /secgate/lib/libsg_xmldom.so
    52  7f396e7c4000-7f396e9c3000 ---p 00032000 08:01 155979                     /secgate/lib/libsg_xmldom.so
    53  7f396e9c3000-7f396e9d6000 rw-p 00031000 08:01 155979                     /secgate/lib/libsg_xmldom.so
    54  7f396e9d6000-7f396ea56000 rw-p 00000000 00:00 0
    55  7f396ea56000-7f396efc8000 r-xp 00000000 08:01 156399                     /secgate/lib/libhs-2.1.so
    56  7f396efc8000-7f396f1c7000 ---p 00572000 08:01 156399                     /secgate/lib/libhs-2.1.so
    57  7f396f1c7000-7f396f1cc000 rw-p 00571000 08:01 156399                     /secgate/lib/libhs-2.1.so
    58  7f396f1cc000-7f396f1e1000 r-xp 00000000 08:01 114701                     /lib64/libz.so.1.2.3
    59  7f396f1e1000-7f396f3e0000 ---p 00015000 08:01 114701                     /lib64/libz.so.1.2.3
    60  7f396f3e0000-7f396f3e1000 r--p 00014000 08:01 114701                     /lib64/libz.so.1.2.3
    61  7f396f3e1000-7f396f3e2000 rw-p 00015000 08:01 114701                     /lib64/libz.so.1.2.3
    62  7f396f3e2000-7f396f46e000 r-xp 00000000 08:01 1663748                    /usr/lib64/libsqlite3.so.0.8.6
    63  7f396f46e000-7f396f66d000 ---p 0008c000 08:01 1663748                    /usr/lib64/libsqlite3.so.0.8.6
    64  7f396f66d000-7f396f670000 rw-p 0008b000 08:01 1663748                    /usr/lib64/libsqlite3.so.0.8.6
    65  7f396f670000-7f396f671000 rw-p 00000000 00:00 0
    66  7f396f671000-7f396f679000 r-xp 00000000 08:01 155914                     /secgate/lib/libnuma.so.1
    67  7f396f679000-7f396f879000 ---p 00008000 08:01 155914                     /secgate/lib/libnuma.so.1
    68  7f396f879000-7f396f87a000 rw-p 00008000 08:01 155914                     /secgate/lib/libnuma.so.1
    69  7f396f87a000-7f396f881000 r-xp 00000000 08:01 114913                     /lib64/librt-2.12.so
    70  7f396f881000-7f396fa80000 ---p 00007000 08:01 114913                     /lib64/librt-2.12.so
    71  7f396fa80000-7f396fa81000 r--p 00006000 08:01 114913                     /lib64/librt-2.12.so
    72  7f396fa81000-7f396fa82000 rw-p 00007000 08:01 114913                     /lib64/librt-2.12.so
    73  7f396fa82000-7f396fc74000 r-xp 00000000 08:01 155932                     /secgate/lib/libsg_crypto.so.1.0.0
    74  7f396fc74000-7f396fe73000 ---p 001f2000 08:01 155932                     /secgate/lib/libsg_crypto.so.1.0.0
    75  7f396fe73000-7f396fe99000 rw-p 001f1000 08:01 155932                     /secgate/lib/libsg_crypto.so.1.0.0
    76  7f396fe99000-7f396fe9d000 rw-p 00000000 00:00 0
    77  7f396fe9d000-7f3970034000 r-xp 00000000 08:01 114900                     /lib64/libc-2.12.so
    78  7f3970034000-7f3970234000 ---p 00197000 08:01 114900                     /lib64/libc-2.12.so
    79  7f3970234000-7f3970238000 r--p 00197000 08:01 114900                     /lib64/libc-2.12.so
    80  7f3970238000-7f3970239000 rw-p 0019b000 08:01 114900                     /lib64/libc-2.12.so
    81  7f3970239000-7f397023e000 rw-p 00000000 00:00 0
    82  7f397023e000-7f3970255000 r-xp 00000000 08:01 114959                     /lib64/libpthread-2.12.so
    83  7f3970255000-7f3970454000 ---p 00017000 08:01 114959                     /lib64/libpthread-2.12.so
    84  7f3970454000-7f3970455000 r--p 00016000 08:01 114959                     /lib64/libpthread-2.12.so
    85  7f3970455000-7f3970456000 rw-p 00017000 08:01 114959                     /lib64/libpthread-2.12.so
    86  7f3970456000-7f397045a000 rw-p 00000000 00:00 0
    87  7f397045a000-7f3970493000 r-xp 00000000 08:01 155990                     /secgate/lib/libevent.so
    88  7f3970493000-7f3970693000 ---p 00039000 08:01 155990                     /secgate/lib/libevent.so
    89  7f3970693000-7f3970695000 rw-p 00039000 08:01 155990                     /secgate/lib/libevent.so
    90  7f3970695000-7f397071c000 r-xp 00000000 08:01 156006                     /secgate/lib/libsg_sc.so
    91  7f397071c000-7f397091c000 ---p 00087000 08:01 156006                     /secgate/lib/libsg_sc.so
    92  7f397091c000-7f3970932000 rw-p 00087000 08:01 156006                     /secgate/lib/libsg_sc.so
    93  7f3970932000-7f3970a02000 rw-p 00000000 00:00 0
    94  7f3970a02000-7f3970a3c000 r-xp 00000000 08:01 155997                     /secgate/lib/libsg_fm.so
    95  7f3970a3c000-7f3970c3b000 ---p 0003a000 08:01 155997                     /secgate/lib/libsg_fm.so
    96  7f3970c3b000-7f3970c44000 rw-p 00039000 08:01 155997                     /secgate/lib/libsg_fm.so
    97  7f3970c44000-7f3970c4a000 rw-p 00000000 00:00 0
    98  7f3970c4a000-7f3970c6a000 r-xp 00000000 08:01 114952                     /lib64/ld-2.12.so
    99  7f3970e05000-7f3970e0c000 r--s 00000000 08:01 1671450                    /usr/lib64/gconv/gconv-modules.cache
   100  7f3970e0c000-7f3970e3c000 r--p 00000000 08:01 222345                     /secgate/etc/conf/locale/zh_CN/LC_MESSAGES/zh_msg.mo
   101  7f3970e3c000-7f3970e48000 rw-s 00000000 00:10 45292                      /dev/shm/sg_log_state
   102  7f3970e48000-7f3970e52000 rw-s 00000000 00:10 45304                      /dev/shm/sg_dbg_state
   103  7f3970e52000-7f3970e5f000 rw-p 00000000 00:00 0
   104  7f3970e67000-7f3970e69000 rw-p 00000000 00:00 0
   105  7f3970e69000-7f3970e6a000 r--p 0001f000 08:01 114952                     /lib64/ld-2.12.so
   106  7f3970e6a000-7f3970e6b000 rw-p 00020000 08:01 114952                     /lib64/ld-2.12.so
   107  7f3970e6b000-7f3970e6c000 rw-p 00000000 00:00 0
   108  7f3971000000-7f3971c00000 rw-s 00000000 00:12 45294                      /mnt/huge/log-log_ring_0
   109  7fff3e721000-7fff3e736000 rw-p 00000000 00:00 0                          [stack]
   110  7fff3e7ff000-7fff3e800000 r-xp 00000000 00:00 0                          [vdso]
   111  ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0                  [vsyscall]



分析:

     1  00400000-0040a000 r-xp 00000000 08:01 156019                             /secgate/bin/ddns    代码段
     2  00609000-0060a000 rw-p 00009000 08:01 156019                             /secgate/bin/ddns    数据段

     3  025e9000-0260a000 rw-p 00000000 00:00 0                                  [heap]    堆

     4  7f3958000000-7f3958021000 rw-p 00000000 00:00 0     各个线程的栈区
      ......    
     13  7f3964dba000-7f39657ba000 rw-p 00000000 00:00 0

本文出自 “天马行空” 博客,请务必保留此出处http://mydiary2014.blog.51cto.com/8869917/1575695

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。