{"id":59749,"date":"2023-10-30T09:00:50","date_gmt":"2023-10-30T01:00:50","guid":{"rendered":"https:\/\/docs.pingcode.com\/?p=59749"},"modified":"2023-10-30T09:00:51","modified_gmt":"2023-10-30T01:00:51","slug":"linux%e7%b3%bb%e7%bb%9f%e5%a6%82%e4%bd%95%e8%a7%a3%e5%86%b3%e5%86%85%e5%ad%98%e8%bf%87%e9%ab%98%e5%92%8c%e6%b3%84%e9%9c%b2%e9%97%ae%e9%a2%98","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/59749.html","title":{"rendered":"Linux\u7cfb\u7edf\u5982\u4f55\u89e3\u51b3\u5185\u5b58\u8fc7\u9ad8\u548c\u6cc4\u9732\u95ee\u9898"},"content":{"rendered":"\n<blockquote class=\"wp-block-quote\">\n<p>\u200b\u5185\u5b58\u8fc7\u9ad8\u548c\u6cc4\u9732\u662fLinux\u7cfb\u7edf\u8fd0\u7ef4\u4e2d\u7684\u5e38\u89c1\u95ee\u9898\u3002\u89e3\u51b3\u65b9\u6cd5\u5305\u62ec\uff1a1.\u8bc6\u522b\u548c\u5b9a\u4f4d\u95ee\u9898\u6765\u6e90\uff1b2.\u4f7f\u7528\u5de5\u5177\u76d1\u63a7\u548c\u8bca\u65ad\uff1b3.\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u5185\u5b58\u6cc4\u9732\uff1b4.\u914d\u7f6e\u548c\u4f18\u5316\u7cfb\u7edf\u8bbe\u7f6e\uff1b5.\u91c7\u53d6\u9884\u9632\u63aa\u65bd\u3002\u9996\u5148\uff0c\u7406\u89e3\u95ee\u9898\u7684\u672c\u8d28\u662f\u89e3\u51b3\u4efb\u4f55\u6280\u672f\u96be\u9898\u7684\u5173\u952e\u3002<\/p>\n<\/blockquote>\n\n\n\n<h2 class=\"wp-block-heading\">1.\u8bc6\u522b\u548c\u5b9a\u4f4d\u95ee\u9898\u6765\u6e90<\/h2>\n\n\n\n<p>\u5728\u5f00\u59cb\u89e3\u51b3\u95ee\u9898\u4e4b\u524d\uff0c\u9996\u5148\u8981\u660e\u786e\u95ee\u9898\u7684\u6765\u6e90\u3002\u5185\u5b58\u6cc4\u9732\u53ef\u80fd\u662f\u7531\u4e8e\u4ee3\u7801\u4e2d\u7684\u7f3a\u9677\uff0c\u6216\u8005\u67d0\u4e9b\u7cfb\u7edf\u914d\u7f6e\u4e0d\u5f53\u5bfc\u81f4\u7684\u3002\u4e86\u89e3\u6cc4\u9732\u7684\u539f\u56e0\u662f\u627e\u5230\u89e3\u51b3\u65b9\u6848\u7684\u5173\u952e\u3002\u4f8b\u5982\uff0c\u4e00\u4e2a\u7a0b\u5e8f\u53ef\u80fd\u5728\u4f7f\u7528\u5185\u5b58\u540e\u6ca1\u6709\u6b63\u786e\u5730\u91ca\u653e\u5b83\uff0c\u6216\u8005\u4e00\u4e2a\u670d\u52a1\u53ef\u80fd\u914d\u7f6e\u5f97\u8fc7\u5927\uff0c\u6d88\u8017\u4e86\u8fc7\u591a\u7684\u7cfb\u7edf\u8d44\u6e90\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">2.\u4f7f\u7528\u5de5\u5177\u76d1\u63a7\u548c\u8bca\u65ad<\/h2>\n\n\n\n<p>Linux\u63d0\u4f9b\u4e86\u4f17\u591a\u7684\u5de5\u5177\u548c\u547d\u4ee4\u6765\u5e2e\u52a9\u4f60\u8bca\u65ad\u5185\u5b58\u4f7f\u7528\u95ee\u9898\uff0c\u5982<strong>top<\/strong>, <strong>htop<\/strong>, <strong>free<\/strong>, <strong>vmstat<\/strong>\u548c<strong>valgrind<\/strong>\u7b49\u3002\u5176\u4e2d\uff0c<strong>valgrind<\/strong>\u662f\u4e00\u4e2a\u5f3a\u5927\u7684\u5185\u5b58\u68c0\u6d4b\u5de5\u5177\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u5f00\u53d1\u4eba\u5458\u627e\u5230\u5185\u5b58\u6cc4\u9732\u7684\u786e\u5207\u4f4d\u7f6e\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">3.\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u5185\u5b58\u6cc4\u9732<\/h2>\n\n\n\n<p>\u4e00\u65e6\u786e\u5b9a\u4e86\u95ee\u9898\u7684\u6765\u6e90\uff0c\u4fee\u590d\u4ee3\u7801\u4e2d\u7684\u5185\u5b58\u6cc4\u9732\u5c31\u53d8\u5f97\u76f8\u5bf9\u7b80\u5355\u3002\u5e38\u89c1\u7684\u505a\u6cd5\u662f\u786e\u4fdd\u6bcf\u6b21\u5206\u914d\u7684\u5185\u5b58\u5728\u4f7f\u7528\u5b8c\u6bd5\u540e\u90fd\u88ab\u6b63\u786e\u91ca\u653e\u3002\u5728C\u548cC++\u4e2d\uff0c\u4f7f\u7528<strong>malloc<\/strong>\u548c<strong>free<\/strong>\u6216<strong>new<\/strong>\u548c<strong>delete<\/strong>\u5bf9\u5185\u5b58\u8fdb\u884c\u7ba1\u7406\u3002\u786e\u4fdd\u6bcf\u6b21<strong>malloc<\/strong>\u6216<strong>new<\/strong>\u7684\u8c03\u7528\u90fd\u6709\u76f8\u5e94\u7684<strong>free<\/strong>\u6216<strong>delete<\/strong>\u6765\u91ca\u653e\u5185\u5b58\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">4.\u914d\u7f6e\u548c\u4f18\u5316\u7cfb\u7edf\u8bbe\u7f6e<\/h2>\n\n\n\n<p>\u9664\u4e86\u4fee\u590d\u4ee3\u7801\u95ee\u9898\uff0c\u8fd8\u53ef\u4ee5\u901a\u8fc7\u8c03\u6574\u7cfb\u7edf\u914d\u7f6e\u6765\u51cf\u5c11\u5185\u5b58\u4f7f\u7528\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u8c03\u6574\u7f13\u5b58\u5927\u5c0f\u3001\u9650\u5236\u670d\u52a1\u7684\u5185\u5b58\u4f7f\u7528\u6216\u8c03\u6574\u865a\u62df\u5185\u5b58\u8bbe\u7f6e\u3002\u8fd9\u4e9b\u8c03\u6574\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539<strong>\/etc\/sysctl.conf<\/strong>\u6587\u4ef6\u6216\u4f7f\u7528<strong>sysctl<\/strong>\u547d\u4ee4\u6765\u5b8c\u6210\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">5.\u91c7\u53d6\u9884\u9632\u63aa\u65bd<\/h2>\n\n\n\n<p>\u9884\u9632\u603b\u662f\u4f18\u4e8e\u6cbb\u7597\u3002\u786e\u4fdd\u4ee3\u7801\u7684\u8d28\u91cf\u3001\u8fdb\u884c\u5b9a\u671f\u7684<a href=\"https:\/\/docs.pingcode.com\/code-review\" target=\"_blank\">\u4ee3\u7801\u5ba1\u67e5<\/a>\u548c\u4f7f\u7528\u81ea\u52a8\u5316\u7684\u6d4b\u8bd5\u5de5\u5177\u6765\u68c0\u6d4b\u5185\u5b58\u6cc4\u9732\u53ef\u4ee5\u5927\u5927\u964d\u4f4e\u95ee\u9898\u51fa\u73b0\u7684\u51e0\u7387\u3002\u53e6\u5916\uff0c\u4fdd\u6301\u7cfb\u7edf\u548c\u8f6f\u4ef6\u7684\u5b9a\u671f\u66f4\u65b0\uff0c\u907f\u514d\u4f7f\u7528\u5df2\u77e5\u5b58\u5728\u5185\u5b58\u6cc4\u9732\u95ee\u9898\u7684\u5e93\u548c\u5de5\u5177\uff0c\u4e5f\u662f\u9884\u9632\u5185\u5b58\u6cc4\u9732\u7684\u6709\u6548\u65b9\u6cd5\u3002<\/p>\n\n\n\n<p>\u7ed3\u8bba\uff1a \u5185\u5b58\u6cc4\u9732\u548c\u8fc7\u9ad8\u7684\u5185\u5b58\u4f7f\u7528\u662fLinux\u7cfb\u7edf\u4e2d\u7684\u5e38\u89c1\u95ee\u9898\uff0c\u4f46\u901a\u8fc7\u6b63\u786e\u7684\u5de5\u5177\u548c\u65b9\u6cd5\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u5b9a\u4f4d\u548c\u4fee\u590d\u8fd9\u4e9b\u95ee\u9898\u3002\u4fdd\u6301\u4ee3\u7801\u7684\u8d28\u91cf\u3001\u5b9a\u671f\u68c0\u67e5\u548c\u9884\u9632\u90fd\u662f\u786e\u4fdd\u7cfb\u7edf\u5065\u5eb7\u8fd0\u884c\u7684\u5173\u952e\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"484\" height=\"300\" src=\"https:\/\/cdn-docs.pingcode.com\/wp-content\/uploads\/2023\/10\/\u5982\u4f55\u5728\u9e92\u9e9f\u64cd\u4f5c\u7cfb\u7edf\u4e0a\u5b89\u88c5\u548c\u7ba1\u7406\u5b57\u4f53-2023-10-30T085853.417.png?x-oss-process=image\/auto-orient,1\/format,webp\" alt=\"\" class=\"wp-image-59750\" \/><\/figure><\/div>\n\n\n<p><strong>\u5e38\u89c1\u95ee\u7b54\uff1a<\/strong><\/p>\n\n\n\n<ul>\n<li><strong>\u95ee\uff1a<\/strong> Linux\u7cfb\u7edf\u4e2d\uff0c\u5982\u4f55\u68c0\u6d4b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\uff1f<\/li>\n\n\n\n<li><strong>\u7b54\uff1a<\/strong> \u53ef\u4ee5\u4f7f\u7528<strong>top<\/strong>\u3001<strong>htop<\/strong>\u6216<strong>free<\/strong>\u7b49\u547d\u4ee4\u6765\u67e5\u770b\u5f53\u524d\u7cfb\u7edf\u7684\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\u4f8b\u5982\uff0c\u4f7f\u7528<strong>free -h<\/strong>\u547d\u4ee4\u53ef\u4ee5\u4ee5\u6613\u8bfb\u7684\u683c\u5f0f\u67e5\u770b\u5185\u5b58\u4f7f\u7528\u91cf\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>\u95ee\uff1a<\/strong> \u5982\u4f55\u786e\u5b9a\u4e00\u4e2a\u8fdb\u7a0b\u662f\u5426\u6709\u5185\u5b58\u6cc4\u6f0f\uff1f<\/li>\n\n\n\n<li><strong>\u7b54\uff1a<\/strong> \u53ef\u4ee5\u4f7f\u7528\u5de5\u5177\u5982<strong>valgrind<\/strong>\u6765\u76d1\u6d4b\u8fdb\u7a0b\u5185\u5b58\u4f7f\u7528\u60c5\u51b5\u3002\u5982\u679c\u4e00\u4e2a\u8fdb\u7a0b\u7684\u5185\u5b58\u4f7f\u7528\u91cf\u6301\u7eed\u589e\u957f\u5e76\u4e14\u6ca1\u6709\u91ca\u653e\uff0c\u90a3\u4e48\u5f88\u53ef\u80fd\u5b58\u5728\u5185\u5b58\u6cc4\u9732\u3002<\/li>\n<\/ul>\n\n\n\n<ul>\n<li><strong>\u95ee\uff1a<\/strong> \u6709\u54ea\u4e9b\u5de5\u5177\u53ef\u4ee5\u5e2e\u52a9\u6211\u5206\u6790Linux\u7cfb\u7edf\u7684\u5185\u5b58\u6cc4\u9732\uff1f<\/li>\n\n\n\n<li><strong>\u7b54\uff1a<\/strong> <strong>valgrind<\/strong>\u3001<strong>memwatch<\/strong>\u548c<strong>mtrace<\/strong>\u90fd\u662f\u5e38\u7528\u7684Linux\u5185\u5b58\u6cc4\u9732\u68c0\u6d4b\u5de5\u5177\u3002\u5176\u4e2d\uff0c<strong>valgrind<\/strong>\u662f\u6700\u4e3a\u5e38\u7528\u548c\u5f3a\u5927\u7684\u5de5\u5177\uff0c\u80fd\u591f\u63d0\u4f9b\u8be6\u7ec6\u7684\u5185\u5b58\u4f7f\u7528\u62a5\u544a\u548c\u6f5c\u5728\u7684\u5185\u5b58\u6cc4\u9732\u4f4d\u7f6e\u3002<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"\u200b\u5185\u5b58\u8fc7\u9ad8\u548c\u6cc4\u9732\u662fLinux\u7cfb\u7edf\u8fd0\u7ef4\u4e2d\u7684\u5e38\u89c1\u95ee\u9898\u3002\u89e3\u51b3\u65b9\u6cd5\u5305\u62ec\uff1a1.\u8bc6\u522b\u548c\u5b9a\u4f4d\u95ee\u9898\u6765\u6e90\uff1b2.\u4f7f\u7528\u5de5\u5177\u76d1\u63a7\u548c\u8bca\u65ad [&hellip;]","protected":false},"author":7,"featured_media":59750,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/59749"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/7"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=59749"}],"version-history":[{"count":0,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/59749\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/59750"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=59749"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=59749"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=59749"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}