{"id":671,"date":"2025-07-27T09:58:25","date_gmt":"2025-07-27T01:58:25","guid":{"rendered":"https:\/\/www.vcidc.net\/blog\/?p=671"},"modified":"2025-07-27T09:58:25","modified_gmt":"2025-07-27T01:58:25","slug":"%e6%b7%b1%e5%85%a5%e4%ba%86%e8%a7%a3pmap%e5%91%bd%e4%bb%a4%ef%bc%9alinux%e7%b3%bb%e7%bb%9f%e4%b8%ad%e8%bf%9b%e7%a8%8b%e5%86%85%e5%ad%98%e6%98%a0%e5%b0%84%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/www.vcidc.net\/blog\/671.html","title":{"rendered":"\u6df1\u5165\u4e86\u89e3pmap\u547d\u4ee4\uff1aLinux\u7cfb\u7edf\u4e2d\u8fdb\u7a0b\u5185\u5b58\u6620\u5c04\u8be6\u89e3"},"content":{"rendered":"<p><p>\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u4f7f\u7528 <strong>pmap<\/strong> \u547d\u4ee4\u5728 Linux \u7cfb\u7edf\u4e0a\u8fdb\u884c\u8fdb\u7a0b\u6620\u5c04\uff0c\u8fd9\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u6765\u663e\u793a\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\u3002\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u5177\u4f53\u7684\u4f8b\u5b50\u6765\u5c55\u793a\u5982\u4f55\u4f7f\u7528 pmap\uff0c\u5305\u62ec\u51c6\u5907\u5de5\u4f5c\u3001\u64cd\u4f5c\u6b65\u9aa4\u3001\u6d89\u53ca\u7684\u5173\u952e\u547d\u4ee4\u548c\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3002<\/p>\n<p style=\"text-align:center\"><img decoding=\"async\" src=\"https:\/\/www.vcidc.net\/blog\/wp-content\/uploads\/2025\/07\/575PZ5n.jpg\" alt=\"\u6df1\u5165\u4e86\u89e3pmap\u547d\u4ee4\uff1aLinux\u7cfb\u7edf\u4e2d\u8fdb\u7a0b\u5185\u5b58\u6620\u5c04\u8be6\u89e3\" title=\"\u6df1\u5165\u4e86\u89e3pmap\u547d\u4ee4\uff1aLinux\u7cfb\u7edf\u4e2d\u8fdb\u7a0b\u5185\u5b58\u6620\u5c04\u8be6\u89e3\"><\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u524d\u7684\u51c6\u5907<\/h2>\n<\/p>\n<p><p>\u5728\u5f00\u59cb\u4e4b\u524d\uff0c\u8bf7\u786e\u4fdd\u60a8\u6709\u4e00\u4e2a Linux \u7cfb\u7edf\u5e76\u4e14\u5df2\u7ecf\u5b89\u88c5\u4e86 <strong>psutil<\/strong> \u5e93\uff0c\u56e0\u4e3a pmap \u662f psutil \u7684\u4e00\u90e8\u5206\u3002\u4ee5\u4e0b\u662f\u5728\u57fa\u4e8e Python \u7684\u73af\u5883\u4e2d\u5b89\u88c5 psutil \u7684\u6b65\u9aa4\uff1a<\/p>\n<\/p>\n<p><pre><code>pip install psutil<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u5b8c\u6210\u4efb\u52a1\u7684\u8be6\u7ec6\u64cd\u4f5c\u6307\u5357<\/h2>\n<\/p>\n<p><h3>\u6b65\u9aa4 1: \u83b7\u53d6\u8fdb\u7a0b ID<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u77e5\u9053\u60a8\u60f3\u8981\u6620\u5c04\u7684\u8fdb\u7a0b\u7684\u8fdb\u7a0b ID (PID)\u3002\u60a8\u53ef\u4ee5\u4f7f\u7528 <strong>ps<\/strong> \u547d\u4ee4\u6765\u83b7\u53d6\u8fd9\u4e2a\u4fe1\u606f\u3002<\/p>\n<\/p>\n<p><pre><code>ps aux | grep [\u8fdb\u7a0b\u540d\u79f0]<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u60f3\u6620\u5c04\u540d\u4e3a <strong>myprocess<\/strong> \u7684\u8fdb\u7a0b\uff0c\u547d\u4ee4\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>ps aux | grep myprocess<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 2: \u4f7f\u7528 pmap \u547d\u4ee4<\/h3>\n<\/p>\n<p><p>\u4e00\u65e6\u60a8\u6709\u4e86 PID\uff0c\u5c31\u53ef\u4ee5\u4f7f\u7528 pmap \u547d\u4ee4\u6765\u67e5\u770b\u8be5\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\u3002<\/p>\n<\/p>\n<p><pre><code>pmap [PID]<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u4f8b\u5982\uff0c\u5982\u679c\u60a8\u5f97\u5230\u7684 PID \u662f 1234\uff0c\u90a3\u4e48\u547d\u4ee4\u5c06\u662f\uff1a<\/p>\n<\/p>\n<p><pre><code>pmap 1234<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h3>\u6b65\u9aa4 3: \u89e3\u91ca\u8f93\u51fa<\/h3>\n<\/p>\n<p><p>\u8fd0\u884c pmap \u547d\u4ee4\u540e\uff0c\u60a8\u5c06\u770b\u5230\u4e00\u4e2a\u8f93\u51fa\uff0c\u5176\u4e2d\u5217\u51fa\u4e86\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u91cd\u8981\u7684\u5217\u548c\u5b83\u4eec\u7684\u610f\u4e49\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>Address<\/strong>: \u5185\u5b58\u5730\u5740\u8303\u56f4<\/li>\n<li><strong>Offset<\/strong>: \u6587\u4ef6\u504f\u79fb\u91cf<\/li>\n<li><strong>Path<\/strong>: \u6e90\u6587\u4ef6\u8def\u5f84<\/li>\n<li><strong>Device<\/strong>: \u8bbe\u5907\u548cinode\u53f7<\/li>\n<li><strong>Size<\/strong>: \u5185\u5b58\u6620\u5c04\u7684\u5927\u5c0f<\/li>\n<\/ul>\n<p><h2>\u6d89\u53ca\u7684\u5173\u952e\u547d\u4ee4\u3001\u4ee3\u7801\u6216\u914d\u7f6e\u793a\u4f8b<\/h2>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5173\u952e\u547d\u4ee4\u548c\u5b83\u4eec\u7684\u7528\u9014\uff1a<\/p>\n<\/p>\n<p><pre><code>ps aux: \u5217\u51fa\u6240\u6709\u8fdb\u7a0b\u53ca\u5176\u8be6\u7ec6\u4fe1\u606f<\/p>\r\n<p>pmap [PID]: \u663e\u793a\u6307\u5b9a\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04<\/p>\r\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u5bf9\u547d\u4ee4\u3001\u4ee3\u7801\u6216\u91cd\u8981\u6982\u5ff5\u7684\u6e05\u6670\u89e3\u91ca<\/h2>\n<\/p>\n<p><p><strong>ps aux<\/strong> \u547d\u4ee4\u7528\u4e8e\u5217\u51fa\u7cfb\u7edf\u4e0a\u7684\u6240\u6709\u8fdb\u7a0b\uff0c\u5305\u62ec\u5b83\u4eec\u7684\u7528\u6237\u3001CPU \u4f7f\u7528\u7387\u3001\u5185\u5b58\u4f7f\u7528\u91cf\u7b49\u3002\u901a\u8fc7\u4f7f\u7528 <code>grep<\/code> \u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u8fc7\u6ee4\u51fa\u7279\u5b9a\u540d\u79f0\u7684\u8fdb\u7a0b\u3002<\/p>\n<\/p>\n<p><p><strong>pmap<\/strong> \u547d\u4ee4\u7528\u4e8e\u663e\u793a\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\uff0c\u8fd9\u5bf9\u4e8e\u8c03\u8bd5\u548c\u6027\u80fd\u5206\u6790\u975e\u5e38\u6709\u7528\u3002<\/p>\n<\/p>\n<p><h2>\u64cd\u4f5c\u8fc7\u7a0b\u4e2d\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3001\u6ce8\u610f\u4e8b\u9879\u6216\u76f8\u5173\u7684\u5b9e\u7528\u6280\u5de7<\/h2>\n<\/p>\n<ul>\n<li><strong>\u6743\u9650\u95ee\u9898<\/strong>: \u5982\u679c\u60a8\u6ca1\u6709\u8db3\u591f\u7684\u6743\u9650\u6765\u67e5\u770b\u67d0\u4e9b\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4f7f\u7528 sudo\u3002<\/li>\n<li><strong>\u547d\u4ee4\u4e0d\u5b58\u5728<\/strong>: \u5982\u679c\u60a8\u6ca1\u6709\u5b89\u88c5 psutil \u6216 pmap\uff0c\u60a8\u9700\u8981\u5148\u5b89\u88c5\u5b83\u4eec\u3002<\/li>\n<li><strong>\u7406\u89e3\u8f93\u51fa<\/strong>: pmap \u7684\u8f93\u51fa\u53ef\u80fd\u770b\u8d77\u6765\u5f88\u590d\u6742\uff0c\u4f46\u7406\u89e3\u5b83\u53ef\u4ee5\u5e2e\u52a9\u60a8\u627e\u5230\u5185\u5b58\u6cc4\u6f0f\u6216\u6027\u80fd\u74f6\u9888\u3002<\/li>\n<\/ul>\n<p><p>\u901a\u8fc7\u9075\u5faa\u4e0a\u8ff0\u6b65\u9aa4\u548c\u6ce8\u610f\u4e8b\u9879\uff0c\u60a8\u5e94\u8be5\u80fd\u591f\u6210\u529f\u5730\u4f7f\u7528 pmap \u6765\u67e5\u770b Linux \u7cfb\u7edf\u4e2d\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\u3002<\/p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u6587\u5c06\u6307\u5bfc\u60a8\u5982\u4f55\u4f7f\u7528 pmap \u547d\u4ee4\u5728 Linux \u7cfb\u7edf\u4e0a\u8fdb\u884c\u8fdb\u7a0b\u6620\u5c04\uff0c\u8fd9\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u53ef\u4ee5\u7528\u6765\u663e\u793a\u8fdb\u7a0b\u7684\u5185\u5b58\u6620\u5c04\u3002\u6211\u4eec\u5c06\u901a\u8fc7\u4e00\u4e2a\u5177\u4f53\u7684\u4f8b\u5b50\u6765\u5c55\u793a\u5982\u4f55\u4f7f\u7528 pmap\uff0c\u5305\u62ec\u51c6\u5907\u5de5\u4f5c\u3001\u64cd\u4f5c\u6b65\u9aa4\u3001\u6d89\u53ca\u7684\u5173\u952e\u547d\u4ee4\u548c\u53ef\u80fd\u9047\u5230\u7684\u95ee\u9898\u3002 \u64cd\u4f5c\u524d\u7684\u51c6\u5907&#8230;<\/p>\n","protected":false},"author":1,"featured_media":672,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[284,285,286],"topic":[],"class_list":["post-671","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-overseas-server","tag-pmap","tag-psutil","tag-286"],"_links":{"self":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/671","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/comments?post=671"}],"version-history":[{"count":1,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/671\/revisions"}],"predecessor-version":[{"id":674,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/posts\/671\/revisions\/674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media\/672"}],"wp:attachment":[{"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/media?parent=671"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/categories?post=671"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/tags?post=671"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.vcidc.net\/blog\/wp-json\/wp\/v2\/topic?post=671"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}