{"id":995,"date":"2014-08-13T02:53:13","date_gmt":"2014-08-13T02:53:13","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=995"},"modified":"2014-08-13T02:53:13","modified_gmt":"2014-08-13T02:53:13","slug":"%e5%a0%86%e7%a9%ba%e9%97%b4%e6%a0%88%e7%a9%ba%e9%97%b4","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/995.html","title":{"rendered":"\u5806\u7a7a\u95f4&amp;\u6808\u7a7a\u95f4&amp;&amp;\u52a8\u6001\u5185\u5b58\u5206\u914d"},"content":{"rendered":"<p>\u8fdc\u79bb\u4e66\u672c\/\u8bfe\u5802\u592a\u4e45\uff0c\u5bf9\u8ba1\u7b97\u673a\u4e2d\u7684\u4e00\u4e9b\u57fa\u672c\u77e5\u8bc6\u90fd\u4e0d\u719f\u6089\u4e86\uff0c\u524d\u4e9b\u5929\u4e00\u76f4\u90fd\u5728\u60f3\u522b\u7684\u4e8b\u60c5\uff0c\u6ca1\u6709\u65f6\u95f4\uff08\u5176\u5b9e\u4eca\u5929\u4e5f\u6ca1\u4ec0\u4e48\u65f6\u95f4\uff0c\u56e0\u4e3a\u660e\u5929\u5c31\u8981\u8003\u79d1\u76ee\u4e8c\u4e86\u2026\u2026\uff09\u53bb\u5b66\u4e60\/\u6574\u7406\u5806\u6808\u65b9\u9762\u7684\u77e5\u8bc6\u70b9\uff0c\u4eca\u5929\u82b1\u4e86\u4e9b\u65f6\u95f4\u628a\u4e4b\u524d\u641c\u96c6\u5230\u7684\u4e00\u4e9b\u5185\u5bb9\u7efc\u5408\u8d77\u6765\uff0c\u81ea\u5df1\u6458\u5f55\/\u8bc6\u8bb0\/\u7406\u89e3\u5982\u4e0b\uff1a<\/p>\n<h6>\u4e00\u4e2a\u7531C\/C++\u7f16\u8bd1\u7684\u7a0b\u5e8f\u5360\u7528\u7684\u5185\u5b58\u5206\u4e3a\u4ee5\u4e0b\u51e0\u4e2a\u90e8\u5206\uff1a<\/h6>\n<p>1\u3001\u6808\u533a\uff08stack\uff09\uff1a\u7531\u7f16\u8bd1\u5668\u81ea\u52a8\u5206\u914d\u91ca\u653e\uff08<span style=\"color: #ff0000;\">\u7f16\u8bd1\u5668\u7528\u5b83\u6765\u5b9e\u73b0\u51fd\u6570\u8c03\u7528<\/span>\uff09\uff0c\u5b58\u653e\u51fd\u6570\u7684\u53c2\u6570\u503c\u3001\u5c40\u90e8\u53d8\u91cf\u7684\u503c\u7b49\uff0c\u5176\u64cd\u4f5c\u65b9\u5f0f\u7c7b\u4f3c\u4e8e\u6570\u636e\u7ed3\u6784\u7684\u6808\uff08\u540e\u8fdb\u5148\u51fa-LIFO\uff09\u3002<\/p>\n<p>2\u3001\u5806\u533a\uff08heap\uff09\uff1a\u4e00\u822c\u662f\u7531\u7a0b\u5e8f\u5458\u5206\u914d\u91ca\u653e\uff0c\u82e5\u7a0b\u5e8f\u5458\u4e0d\u91ca\u653e\u7684\u8bdd\uff0c\u7a0b\u5e8f\u7ed3\u675f\u65f6\u53ef\u80fd\u7531OS\u56de\u6536\uff0c\u503c\u5f97\u6ce8\u610f\u7684\u662f\u5b83\u4e0e\u6570\u636e\u7ed3\u6784\u7684\u5806\u662f\u4e24\u56de\u4e8b\uff0c\u5206\u914d\u65b9\u5f0f\u5012\u662f\u7c7b\u4f3c\u4e8e\u6570\u636e\u7ed3\u6784\u7684\u94fe\u8868\u3002<\/p>\n<p>3\u3001\u5168\u5c40\u533a\uff08static\uff09\uff1a\u4e5f\u53eb\u9759\u6001\u6570\u636e\u5185\u5b58\u7a7a\u95f4\uff0c\u5b58\u50a8\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\uff0c\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u7684\u5b58\u50a8\u662f\u653e\u4e00\u5757\u7684\uff0c\u521d\u59cb\u5316\u7684\u5168\u5c40\u53d8\u91cf\u548c\u9759\u6001\u53d8\u91cf\u653e\u4e00\u5757\u533a\u57df\uff0c\u6ca1\u6709\u521d\u59cb\u5316\u7684\u5728\u76f8\u90bb\u7684\u53e6\u4e00\u5757\u533a\u57df\uff0c\u7a0b\u5e8f\u7ed3\u675f\u540e\u7531\u7cfb\u7edf\u91ca\u653e\u3002<\/p>\n<p>4\u3001\u6587\u5b57\u5e38\u91cf\u533a\uff08.text\uff09\uff1a\u5e38\u91cf\u5b57\u7b26\u4e32\u5c31\u662f\u653e\u5728\u8fd9\u91cc\uff0c\u7a0b\u5e8f\u7ed3\u675f\u540e\u7531\u7cfb\u7edf\u91ca\u653e\u3002<\/p>\n<p>5\u3001\u7a0b\u5e8f\u4ee3\u7801\u533a\uff08.data\uff09\uff1a\u5b58\u653e\u51fd\u6570\u4f53\u7684\u4e8c\u8fdb\u5236\u4ee3\u7801\u3002<\/p>\n<hr \/>\n<p>\u4e0b\u9762\u7ed9\u51fa\u4e00\u5e45\u6211\u81ea\u5df1\u53c2\u8003\u300a\u6df1\u5165\u7406\u89e3\u8ba1\u7b97\u673a\u7cfb\u7edf\u300b\u753b\u7684\u793a\u610f\u56fe\uff1a<\/p>\n<figure id=\"attachment_996\" aria-describedby=\"caption-attachment-996\" style=\"width: 565px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/08\/virtual_mem_addr.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-996\" src=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/08\/virtual_mem_addr.png\" alt=\"\u8fdb\u7a0b\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4\" width=\"565\" height=\"409\" \/><\/a><figcaption id=\"caption-attachment-996\" class=\"wp-caption-text\">\u8fdb\u7a0b\u7684\u865a\u62df\u5730\u5740\u7a7a\u95f4<\/figcaption><\/figure>\n<h5>\u5806\u548c\u6808\u7684\u533a\u522b\uff1a<\/h5>\n<h6>1\u3001\u7531\u4ee5\u4e0a\u63cf\u8ff0\u53ef\u77e5\uff0c\u5806\u548c\u6808\u5728\u7a0b\u5e8f\u4e2d\u7684\u5185\u5b58\u5206\u914d\u65b9\u5f0f\u4e0d\u540c\u3002<\/h6>\n<h6>2\u3001\u7533\u8bf7\u548c\u54cd\u5e94\u4e0d\u540c\uff1a<\/h6>\n<p>\uff081\uff09\u7533\u8bf7\u65b9\u5f0f\uff1a<\/p>\n<p>stack\u7531\u7cfb\u7edf\u81ea\u52a8\u5206\u914d\uff0c\u7cfb\u7edf\u6536\u56de\uff1bheap\u9700\u8981\u7a0b\u5e8f\u5458\u81ea\u5df1\u7533\u8bf7\uff0cC\u8bed\u8a00\u4e2d\u7528\u51fd\u6570malloc\u5206\u914d\u7a7a\u95f4\uff0c\u7528free\u91ca\u653e\uff0cC++\u7528new\u5206\u914d\uff0c\u7528delete\u91ca\u653e\u3002<\/p>\n<p>\uff082\uff09\u7533\u8bf7\u540e\u7cfb\u7edf\u7684\u54cd\u5e94\uff1a<\/p>\n<ul>\n<li>\u6808\uff1a\u53ea\u8981\u6808\u7684\u5269\u4f59\u7a7a\u95f4\u5927\u4e8e\u6240\u7533\u8bf7\u7684\u7a7a\u95f4\uff0c\u7cfb\u7edf\u5c06\u4e3a\u7a0b\u5e8f\u63d0\u4f9b\u5185\u5b58\uff0c\u5426\u5219\u5c06\u62a5\u5f02\u5e38\u63d0\u793a\u6808\u6ea2\u51fa\uff08stack overflow\uff09\u3002<\/li>\n<li>\u5806\uff1a\u9996\u5148\u5e94\u8be5\u77e5\u9053\u64cd\u4f5c\u7cfb\u7edf\u6709\u4e00\u4e2a\u8bb0\u5f55\u5185\u5b58\u5730\u5740\u7684\u94fe\u8868\uff0c\u5f53\u7cfb\u7edf\u6536\u5230\u7a0b\u5e8f\u7684\u7533\u8bf7\u65f6\uff0c\u4f1a\u904d\u5386\u8be5\u94fe\u8868\uff0c\u5bfb\u627e\u7b2c\u4e00\u4e2a\u7a7a\u95f4\u5927\u4e8e\u6240\u7533\u8bf7\u7684\u7a7a\u95f4\u7684\u5806\u7ed3\u70b9\uff0c\u7136\u540e\u5c06\u8be5\u7ed3\u70b9\u4ece\u7a7a\u95f2\u7ed3\u70b9\u94fe\u8868\u4e2d\u5220\u9664\uff0c\u5e76\u5c06\u8be5\u7ed3\u70b9\u7684\u7a7a\u95f4\u5206\u914d\u7ed9\u7a0b\u5e8f\u3002\u53e6\u5916\uff0c\u5bf9\u4e8e\u5927\u591a\u6570\u7cfb\u7edf\uff0c\u4f1a\u5728\u8fd9\u5757\u5185\u5b58\u7a7a\u95f4\u4e2d\u7684\u9996\u5730\u5740\u5904\u8bb0\u5f55\u672c\u6b21\u5206\u914d\u7684\u5927\u5c0f\uff0c\u8fd9\u6837\u4ee3\u7801\u4e2d\u7684delete\u6216free\u8bed\u53e5\u5c31\u80fd\u591f\u6b63\u786e\u7684\u91ca\u653e\u672c\u5185\u5b58\u7a7a\u95f4\u3002\u53e6\u5916\uff0c\u7531\u4e8e\u627e\u5230\u7684\u5806\u7ed3\u70b9\u7684\u5927\u5c0f\u4e0d\u4e00\u5b9a\u6b63\u597d\u7b49\u4e8e\u7533\u8bf7\u7684\u5927\u5c0f\uff0c\u7cfb\u7edf\u4f1a\u5c06\u591a\u4f59\u7684\u90a3\u90e8\u5206\u91cd\u65b0\u653e\u5165\u7a7a\u95f2\u94fe\u8868\u4e2d\u3002<\/li>\n<\/ul>\n<h6>3\u3001\u7533\u8bf7\u7684\u5927\u5c0f\u9650\u5236\u4e0d\u540c\uff1a<\/h6>\n<ul>\n<li>\u6808\uff1a\u5728Windows\u4e0b\uff0c<span style=\"color: #ff0000;\">\u6808\u662f\u7531\u9ad8\u5411\u4f4e\u5730\u5740\u6269\u5c55\u7684<\/span>\u6570\u636e\u7ed3\u6784\uff0c\u662f\u4e00\u5757\u8fde\u7eed\u7684\u5185\u5b58\u533a\u57df\uff0c\u6808\u9876\u7684\u5730\u5740\u548c\u6808\u7684\u6700\u5927\u5bb9\u91cf\u662f\u7cfb\u7edf\u9884\u5148\u89c4\u5b9a\u597d\u7684\uff0c\u80fd\u4ece\u6808\u83b7\u5f97\u7684\u7a7a\u95f4\u8f83\u5c0f\u3002{\u5730\u5740\u4ece\u9ad8\u5411\u4f4e}<\/li>\n<li>\u5806\uff1a<span style=\"color: #ff0000;\">\u5806\u662f\u7531\u4f4e\u5411\u9ad8\u5730\u5740\u6269\u5c55\u7684<\/span>\u6570\u636e\u7ed3\u6784\uff0c\u662f\u4e0d\u8fde\u7eed\u7684\u5185\u5b58\u533a\u57df\uff0c\u8fd9\u662f\u7531\u4e8e\u7cfb\u7edf\u662f\u7531\u94fe\u8868\u5728\u5b58\u50a8\/\u7ec4\u7ec7\u7a7a\u95f2\u5185\u5b58\u5730\u5740\uff0c\u81ea\u7136\u5806\u5c31\u662f\u4e0d\u8fde\u7eed\u7684\u5185\u5b58\u533a\u57df\uff0c\u4e14\u94fe\u8868\u7684\u904d\u5386\u4e5f\u662f\u4ece\u4f4e\u5730\u5740\u5411\u9ad8\u5730\u5740\u904d\u5386\u7684\uff0c\u5806\u7684\u5927\u5c0f\u53d7\u9650\u4e8e\u8ba1\u7b97\u673a\u7cfb\u7edf\u7684\u6709\u6548\u865a\u62df\u5185\u5b58\u7a7a\u95f4\uff0c\u56e0\u6b64\uff0c\u5806\u83b7\u5f97\u7684\u7a7a\u95f4\u6bd4\u8f83\u7075\u6d3b\uff0c\u4e5f\u6bd4\u8f83\u5927\u3002<\/li>\n<\/ul>\n<h6>4\u3001\u7533\u8bf7\u7684\u6548\u7387\u4e0d\u540c\uff1a<\/h6>\n<ul>\n<li>\u6808\uff1a\u6808\u7531\u7cfb\u7edf\u81ea\u52a8\u5206\u914d\uff0c\u901f\u5ea6\u5feb\uff0c\u4f46\u662f\u7a0b\u5e8f\u5458\u65e0\u6cd5\u63a7\u5236\u3002<\/li>\n<li>\u5806\uff1a\u5806\u662f\u7531\u7a0b\u5e8f\u5458\u81ea\u5df1\u5206\u914d\uff0c\u901f\u5ea6\u8f83\u6162\uff0c\u5bb9\u6613\u4ea7\u751f\u788e\u7247\uff0c\u4e0d\u8fc7\u7528\u8d77\u6765\u65b9\u4fbf\u3002<\/li>\n<\/ul>\n<h6>5\u3001\u5806\u548c\u6808\u7684\u5b58\u50a8\u5185\u5bb9\u4e0d\u540c\uff1a<\/h6>\n<ul>\n<li>\u6808\uff1a\u5728\u51fd\u6570\u8c03\u7528\u65f6\uff0c\u7b2c\u4e00\u4e2a\u8fdb\u6808\u7684\u662f\u4e3b\u51fd\u6570\u4e2d\u51fd\u6570\u8c03\u7528\u540e\u7684\u4e0b\u4e00\u6761\u6307\u4ee4\u7684\u5730\u5740\uff0c\u7136\u540e\u662f\u51fd\u6570\u7684\u5404\u4e2a\u53c2\u6570\uff0c\u5728\u5927\u591a\u6570\u7684C\u7f16\u8bd1\u5668\u4e2d\uff0c\u53c2\u6570\u662f\u4ece\u53f3\u5f80\u5de6\u5165\u6808\u7684\uff0c\u5f53\u672c\u6b21\u51fd\u6570\u8c03\u7528\u7ed3\u675f\u540e\uff0c\u5c40\u90e8\u53d8\u91cf\u5148\u51fa\u6808\uff0c\u7136\u540e\u662f\u53c2\u6570\uff0c\u6700\u540e\u6808\u9876\u6307\u9488\u6307\u5411\u6700\u5f00\u59cb\u5b58\u7684\u5730\u5740\uff0c\u4e5f\u5c31\u662f\u4e3b\u51fd\u6570\u4e2d\u7684\u4e0b\u4e00\u6761\u6307\u4ee4\u3002<\/li>\n<li>\u5806\uff1a\u4e00\u822c\u662f\u5728\u5806\u7684\u5934\u90e8\u7528\u4e00\u4e2a\u5b57\u8282\u5b58\u653e\u5806\u7684\u5927\u5c0f(\u4fbf\u4e8e\u5185\u5b58\u7a7a\u95f4\u7684\u7ec4\u7ec7\u548c\u91ca\u653e)\uff0c\u5177\u4f53\u5185\u5bb9\u7531\u7a0b\u5e8f\u5458\u5b89\u6392\u3002<\/li>\n<\/ul>\n<p>\u53c2\u8003\u5730\u5740\uff1a<a href=\"http:\/\/blog.163.com\/hangqiang321@yeah\/blog\/static\/164202800201181453113213\/\" target=\"_blank\">\u6808\u7a7a\u95f4\u548c\u5806\u7a7a\u95f4 &#8211; \u6b87\u7684\u65e5\u5fd7<\/a><\/p>\n<p>***********************************************************<\/p>\n<h5>\u52a8\u6001\u5185\u5b58\u5206\u914d<\/h5>\n<h6>\u524d\u8a00<\/h6>\n<p>1.\u6570\u7ec4\u7684\u5143\u7d20\u5b58\u50a8\u4e8e\u5185\u5b58\u4e2d\u8fde\u7eed\u7684\u4f4d\u7f6e\u4e0a\u3002\u5f53\u4e00\u4e2a\u6570\u7ec4\u88ab\u58f0\u660e\u65f6\uff0c\u5b83\u6240\u9700\u8981\u7684\u5185\u5b58\u5728\u7f16\u8bd1\u65f6\u5c31\u88ab\u5206\u914d[\u56fa\u5b9a\u5927\u5c0f]\u3002<\/p>\n<p>2.\u4f46\u662f\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u5206\u914d\u5728\u8fd0\u884c\u65f6\u4e3a\u5b83\u5206\u914d\u5185\u5b58\u3002<\/p>\n<p>3.\u4e3a\u4ec0\u4e48\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u5206\u914d\uff1f<\/p>\n<p style=\"padding-left: 30px;\">1&gt;\u5f53\u4f7f\u7528\u6570\u7ec4\u65f6\uff0c\u5fc5\u987b\u7528\u4e00\u4e2a\u5e38\u91cf\u6765\u6307\u5b9a\u6570\u7ec4\u7684\u957f\u5ea6\u3002\u4f46\u662f\uff0c\u6709\u65f6\u5019\uff0c\u6570\u7ec4\u7684\u957f\u5ea6\u5e38\u5e38\u5728\u8fd0\u884c\u65f6\u624d\u77e5\u9053\u3002\u56e0\u6b64\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u6211\u4eec\u901a\u5e38\u91c7\u53d6\u58f0\u660e\u4e00\u4e2a\u8f83\u5927\u7684\u6570\u7ec4\uff0c\u5b83\u53ef\u4ee5\u5bb9\u7eb3\u53ef\u80fd\u51fa\u73b0\u7684\u6700\u591a\u5143\u7d20\u3002<\/p>\n<p style=\"padding-left: 30px;\">2&gt;\u8be5\u65b9\u6cd5\u7684\u4f18\u70b9\u662f\uff1a\u7b80\u5355\u3002<\/p>\n<p style=\"padding-left: 30px;\">3&gt;\u5b83\u7684\u7f3a\u70b9\u662f\uff1a<\/p>\n<p style=\"padding-left: 60px;\">\u00d8 <span style=\"color: #ff0000;\">\u8fd9\u79cd\u58f0\u660e\u5728\u7a0b\u5e8f\u4e2d\u5f15\u5165\u4e86\u4eba\u4e3a\u7684\u9650\u5236<\/span>\uff0c\u5982\u679c\u7a0b\u5e8f\u9700\u8981\u4f7f\u7528\u7684\u5143\u7d20\u6570\u91cf\u8d85\u8fc7\u4e86\u58f0\u660e\u7684\u957f\u5ea6\uff0c\u5b83\u5c31\u65e0\u6cd5\u5904\u7406\u8fd9\u79cd\u60c5\u51b5\u3002\u8981\u907f\u514d\u8fd9\u79cd\u60c5\u51b5\uff0c\u6700\u7b80\u5355\u7684\u65b9\u6cd5\u5c31\u662f\u628a\u6570\u7ec4\u58f0\u660e\u7684\u66f4\u5927\u4e00\u4e9b\u3002<br \/>\n\u00d8 \u5982\u679c\u7a0b\u5e8f\u5b9e\u9645\u9700\u8981\u7684\u5143\u7d20\u6570\u91cf\u6bd4\u8f83\u5c11\u65f6\uff0c<span style=\"color: #ff0000;\">\u5de8\u578b\u6570\u7ec4\u7684\u7edd\u5927\u90e8\u5206\u5185\u5b58\u7a7a\u95f4\u90fd\u88ab\u6d6a\u8d39\u4e86<\/span>\u3002<br \/>\n\u00d8 <span style=\"color: #ff0000;\">\u5982\u679c\u8f93\u5165\u7684\u6570\u636e\u8d85\u8fc7\u4e86\u6570\u7ec4\u7684\u5bb9\u7eb3\u8303\u56f4\u65f6\uff0c\u7a0b\u5e8f\u5fc5\u987b\u4ee5\u4e00\u79cd\u5408\u7406\u7684\u65b9\u5f0f\u4f5c\u51fa\u54cd\u5e94<\/span>\u3002<\/p>\n<h6>\u4e00\u3001malloc \u548c free<\/h6>\n<p>1.C\u51fd\u6570\u5e93\u63d0\u4f9b\u4e86\u4e24\u4e2a\u51fd\u6570\uff0cmalloc\u548cfree\uff0c\u5206\u522b\u7528\u4e8e\u6267\u884c\u52a8\u6001\u5185\u5b58\u5206\u914d\u548c\u91ca\u653e\u3002\u8fd9\u4e9b\u51fd\u6570\u7ef4\u62a4\u4e00\u4e2a\u53ef\u7528\u5185\u5b58\u3002<\/p>\n<p>2.\u5f53\u4e00\u4e2a\u7a0b\u5e8f\u53e6\u5916\u9700\u8981\u4e00\u4e9b\u5185\u5b58\u65f6\uff0c\u5b83\u5c31\u8c03\u7528malloc\u51fd\u6570\uff0cmalloc\u4ece\u5185\u5b58\u6c60\u4e2d\u63d0\u53d6\u4e00\u5757\u5408\u9002\u7684\u5185\u5b58\u3002\u5e76\u5411\u8be5\u7a0b\u5e8f\u8fd4\u56de\u4e00\u4e2a\u6307\u5411\u8fd9\u5757\u5185\u5b58\u7684\u6307\u9488\u3002\u8fd9\u5757\u5185\u5b58\u6b64\u65f6\u5e76\u6ca1\u6709\u4ee5\u4efb\u4f55\u65b9\u5f0f\u8fdb\u884c\u521d\u59cb\u5316\u3002\u5982\u679c\u8981\u5bf9\u5176\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u8981\u4e48\u81ea\u5df1\u52a8\u624b\u8fdb\u884c\u521d\u59cb\u5316\uff0c\u8981\u4e48\u4f7f\u7528calloc()\u51fd\u6570\u3002\u5f53\u4e00\u5757\u4ee5\u524d\u5206\u914d\u7684\u5185\u5b58\u4e0d\u5728\u4f7f\u7528\u65f6\uff0c\u7a0b\u5e8f\u8c03\u7528free\u51fd\u6570\u628a\u5b83\u5f52\u8fd8\u7ed9\u5185\u5b58\u6c60\u4f9b\u4ee5\u540e\u4f7f\u7528\u3002<\/p>\n<p>3.\u8fd9\u4e24\u4e2a\u51fd\u6570\u7684\u539f\u578b\u5982\u4e0b\uff0c\u90fd\u5728\u5934\u6587\u4ef6stdlib.h\u4e2d\u58f0\u660e\uff1a<\/p>\n<p style=\"padding-left: 30px;\">void *malloc(size_t size);<br \/>\nvoid free(void *pointer);<\/p>\n<p>4.malloc\u7684\u53c2\u6570\u5c31\u662f\u9700\u8981\u5206\u914d\u7684\u5185\u5b58\u5b57\u8282\u6570\u3002\u5982\u679c\u5185\u5b58\u6c60\u4e2d\u7684\u53ef\u7528\u5185\u5b58\u53ef\u4ee5\u6ee1\u8db3\u8fd9\u4e2a\u9700\u6c42\uff0cmalloc\u5c31\u8fd4\u56de\u4e00\u4e2a\u6307\u5411\u88ab\u5206\u914d\u7684\u5185\u5b58\u5757\u8d77\u59cb\u4f4d\u7f6e\u7684\u6307\u9488\u3002<br \/>\n1&gt;<span style=\"color: #ff0000;\">malloc\u6240\u5206\u914d\u7684\u662f\u4e00\u5757\u8fde\u7eed\u7684\u5185\u5b58<\/span>\u3002\u4f8b\u5982\uff1a\u5982\u679c\u8bf7\u6c42\u5206\u914d100\u4e2a\u5b57\u8282\u7684\u5185\u5b58\uff0c\u90a3\u4e48\u5b83\u5b9e\u9645\u5206\u914d\u7684\u5185\u5b58\u5c31\u662f100\u4e2a\u8fde\u7eed\u7684\u5b57\u8282\uff0c\u5e76\u4e0d\u4f1a\u5206\u5f00\u4f4d\u4e8e\u4e24\u5757\u6216\u591a\u5757\u4e0d\u540c\u7684\u5185\u5b58\u3002\u540c\u65f6\uff0cmalloc\u5b9e\u9645\u5206\u914d\u7684\u5185\u5b58\u6709\u53ef\u80fd\u6bd4\u4f60\u8bf7\u6c42\u7684\u7a0d\u5fae\u591a\u4e00\u70b9\u3002\u4f46\u662f\u8fd9\u662f\u7531\u7f16\u8bd1\u5668\u5b9a\u4e49\u7684\u3002<br \/>\n2&gt;\u5982\u679c\u5185\u5b58\u6c60\u662f\u7a7a\u7684\uff0c\u6216\u8005\u5b83\u7684\u53ef\u7528\u5185\u5b58\u65e0\u6cd5\u6ee1\u8db3\u8981\u6c42\u65f6\u3002\u5728\u8be5\u60c5\u51b5\u4e0b\uff0cmalloc()\u51fd\u6570\u5411\u64cd\u4f5c\u7cfb\u7edf\u8bf7\u6c42\uff0c\u8981\u6c42\u5f97\u5230\u66f4\u591a\u5730\u5185\u5b58\uff0c\u5e76\u5728\u8fd9\u5757\u5185\u5b58\u4e0a\u6267\u884c\u5206\u914d\u4efb\u52a1\u3002\u5982\u679c\u64cd\u4f5c\u7cfb\u7edf\u65e0\u6cd5\u5411malloc\u63d0\u4f9b\u66f4\u591a\u7684\u5185\u5b58\uff0cmalloc\u5c31\u8fd4\u56de\u4e00\u4e2aNULL\u6307\u9488\u3002\u56e0\u6b64\uff0c<span style=\"color: #ff0000;\">\u8981\u5bf9\u6bcf\u4e2a\u4ecemalloc\u8fd4\u56de\u7684\u6307\u9488\u90fd\u8fdb\u884c\u68c0\u67e5\uff0c\u786e\u4fdd\u5b83\u5e76\u975eNULL\u662f\u975e\u5e38\u91cd\u8981\u7684<\/span>\u3002<\/p>\n<p>5.free\u7684\u53c2\u6570\u5fc5\u987b\u8981\u4e48\u662fNULL\uff0c\u8981\u4e48\u662f\u4e00\u4e2a\u5148\u524d\u4ecemalloc\u3001calloc\u6216realloc\u8fd4\u56de\u7684\u6570\u503c\u3002\u60f3free\u4f20\u9012\u4e00\u4e2aNULL\u53c2\u6570\u4e0d\u4f1a\u4ea7\u751f\u4efb\u4f55\u6548\u679c\u3002<\/p>\n<p>6.malloc\u5e76\u4e0d\u77e5\u9053\u8bf7\u6c42\u7684\u5185\u5b58\u9700\u8981\u5b58\u50a8\u7684\u662f\u6574\u578b\u3001\u6d6e\u70b9\u503c\u3001\u7ed3\u6784\u8fd8\u662f\u6570\u7ec4\u3002malloc\u8fd4\u56de\u4e00\u4e2a\u7c7b\u578b\u4e3avoid *\u7684\u6307\u9488\u3002\u5728\u6807\u51c6\u4e2d\u8868\u793a\u4e00\u4e2avoid *\u7c7b\u578b\u7684\u6307\u9488\u53ef\u4ee5\u8f6c\u6362\u4e3a\u5176\u4ed6\u4efb\u4f55\u7c7b\u578b\u7684\u6307\u9488\u3002\u56e0\u6b64\uff0c<span style=\"color: #ff0000;\">\u5728\u4f7f\u7528\u524d\uff0c\u8981\u8fdb\u884c\u5f3a\u5236\u7c7b\u578b\u8f6c\u6362<\/span>\u3002<\/p>\n<h6>\u4e8c\u3001calloc\u548crealloc<\/h6>\n<p>1.\u8fd8\u6709\u4e24\u4e2a\u5185\u5b58\u5206\u914d\u51fd\u6570\uff0ccalloc\u548crealloc\u3002\u5b83\u4eec\u7684\u539f\u578b\u5982\u4e0b\uff1a<br \/>\nvoid *calloc(size_t num_elements,size_t element_size);<br \/>\nvoid realloc(void *ptr,size_t new_size);<\/p>\n<p>2.calloc\u4e5f\u7528\u4e8e\u5206\u914d\u5185\u5b58\u3002malloc\u548ccalloc\u4e4b\u95f4\u7684\u533a\u522b\u662f\u540e\u8005\u5728\u8fd4\u56de\u6307\u5411\u5185\u5b58\u7684\u6307\u9488\u4e4b\u524d\u628a\u5b83\u521d\u59cb\u5316\u4e3a0\u3002\u4f46\u5982\u679c\u7a0b\u5e8f\u53ea\u662f\u60f3\u628a\u4e00\u4e9b\u503c\u5b58\u50a8\u5230\u6570\u7ec4\u4e2d\uff0c\u90a3\u4e48\u8fd9\u4e2a\u521d\u59cb\u5316\u8fc7\u7a0b\u7eaf\u5c5e\u6d6a\u8d39\u65f6\u95f4\u3002<\/p>\n<p>3.calloc\u548cmalloc\u4e4b\u95f4\u53e6\u4e00\u4e2a\u8f83\u5c0f\u7684\u533a\u522b\u662f\u5b83\u4eec\u8bf7\u6c42\u5185\u5b58\u6570\u91cf\u7684\u65b9\u5f0f\u4e0d\u540c\u3002calloc\u7684\u53c2\u6570\u5305\u62ec\u6240\u9700\u5143\u7d20\u7684\u6570\u91cf\u548c\u6bcf\u4e2a\u5143\u7d20\u7684\u5b57\u8282\u6570\u3002\u6839\u636e\u8fd9\u4e9b\u503c\uff0c\u5b83\u80fd\u591f\u8ba1\u7b97\u51fa\u603b\u5171\u9700\u8981\u5206\u914d\u7684\u5185\u5b58\u3002<\/p>\n<p>4.realloc\u51fd\u6570\u7528\u4e8e\u4fee\u6539\u4e00\u4e2a\u539f\u5148\u5df2\u7ecf\u5206\u914d\u7684\u5185\u5b58\u5757\u5927\u5c0f\u3002<br \/>\n1&gt;\u4f7f\u7528\u8fd9\u4e2a\u51fd\u6570\uff0c\u4f60\u53ef\u4ee5\u4f7f\u4e00\u5757\u5185\u5b58\u6269\u5927\u6216\u7f29\u5c0f\u3002\u5982\u679c\u5b83\u7528\u4e8e\u6269\u5927\u4e00\u4e2a\u5185\u5b58\u5757\uff0c\u90a3\u4e48\u8fd9\u5757\u5185\u5b58\u539f\u5148\u7684\u5185\u5bb9\u4f9d\u7136\u4fdd\u7559\uff0c\u65b0\u589e\u52a0\u7684\u5185\u5b58\u6dfb\u52a0\u5230\u539f\u5148\u5185\u5b58\u5757\u7684\u540e\u9762\uff0c\u65b0\u5185\u5b58\u5e76\u672a\u4ee5\u4efb\u4f55\u65b9\u6cd5\u8fdb\u884c\u521d\u59cb\u5316\u3002<br \/>\n2&gt;\u5982\u679c\u5b83\u7528\u4e8e\u7f29\u5c0f\u4e00\u5757\u5185\u5b58\u5757\uff0c\u8be5\u5185\u5b58\u5757\u5c3e\u90e8\u7684\u90e8\u5206\u5185\u5b58\u4fbf\u88ab\u62ff\u6389\uff0c\u5269\u4f59\u90e8\u5206\u5185\u5b58\u7684\u539f\u5148\u5185\u5bb9\u4f9d\u7136\u4fdd\u7559\u3002<br \/>\n3&gt;\u5982\u679c\u539f\u5148\u7684\u5185\u5b58\u5757\u65e0\u6cd5\u6539\u53d8\u5927\u5c0f\uff0crealloc\u5c06\u5206\u914d\u53e6\u4e00\u5757\u6b63\u786e\u5927\u5c0f\u7684\u5185\u5b58\uff0c\u5e76\u628a\u539f\u5148\u90a3\u5757\u5185\u5b58\u7684\u5185\u5bb9\u590d\u5236\u5230\u65b0\u7684\u5757\u4e0a\u3002\u56e0\u6b64\uff0c\u5728\u4f7f\u7528realloc\u4e4b\u540e\uff0c\u5c31\u4e0d\u80fd\u518d\u4f7f\u7528\u6307\u5411\u65e7\u5185\u5b58\u7684\u6307\u9488\uff0c\u800c\u662f\u5e94\u8be5\u8be5\u7528realloc\u6240\u8fd4\u56de\u7684\u65b0\u6307\u9488\u3002<br \/>\n4&gt;\u5982\u679crealloc\u51fd\u6570\u7684\u7b2c\u4e00\u4e2a\u53c2\u6570\u662fNULL,\u90a3\u4e48\u5b83\u7684\u884c\u4e3a\u5c31\u548cmalloc\u4e00\u6a21\u4e00\u6837\u3002<\/p>\n<h6>\u4e09\u3001\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u5206\u914d\u5b9e\u4f8b<\/h6>\n<p>1.\u4f7f\u7528malloc\u5206\u914d\u4e00\u5757\u5185\u5b58<\/p>\n<pre class=\"lang:default decode:true\">int *pi;\n\/* ... *\/\npi = malloc(100);\nif (pi == NULL){\n    printf(\"Outof memory!n\");\n    exit(1);\n}<\/pre>\n<p>\u7b26\u53f7NULL\u5b9a\u4e49\u4e8estdio.h\uff0c\u5b83\u5b9e\u9645\u4e0a\u662f\u5b57\u7b26\u503c\u5e38\u91cf0\u3002<br \/>\n1&gt;\u5982\u679c\u5185\u5b58\u5206\u914d\u6210\u529f\uff0c\u90a3\u4e48\u5f97\u5230\u4e86\u4e00\u4e2a\u6307\u5411100\u4e2a\u5b57\u8282\u7684\u6307\u9488\u3002\u5728\u6574\u578b\u4e3a4\u4e2a\u5b57\u8282\u7684\u673a\u5668\u4e0a\uff0c\u8fd9\u5757\u5185\u5b58\u5c06\u88ab\u5f53\u4f5c25\u4e2a\u6574\u578b\u5143\u7d20\u7684\u6570\u7ec4\uff0c\u56e0\u4e3api\u662f\u4e00\u4e2a\u6307\u5411\u6574\u578b\u7684\u6307\u9488\u3002<br \/>\n2&gt;\u4f46\u662f\uff0c\u4f7f\u7528\u4e0a\u9762\u7684\u7a0b\u5e8f\u53ef\u79fb\u690d\u6027\u8f83\u5dee\uff1a<br \/>\n\u53ef\u4ee5\u4f7f\u7528\u5982\u4e0b\u7684\u65b9\u6cd5\uff1a<\/p>\n<pre class=\"lang:default decode:true\">pi = malloc(25 *sizeof(int));<\/pre>\n<p>\u4f7f\u7528\u8be5\u65b9\u6cd5\uff0c\u5373\u4f7f\u5728\u6574\u6570\u957f\u5ea6\u4e0d\u540c\u7684\u673a\u5668\u4e0a\uff0c\u5b83\u4e5f\u80fd\u83b7\u5f97\u6b63\u786e\u7684\u7ed3\u679c\u3002<br \/>\n3&gt;\u5df2\u7ecf\u6709\u4e86\u6307\u9488\uff0c\u5982\u4f55\u4f7f\u7528\u8fd9\u5757\u5185\u5b58\u5462\u3002\u53ef\u4ee5\u4f7f\u7528\u95f4\u63a5\u8bbf\u95ee\u548c\u6307\u9488\u8fd0\u7b97\u6765\u8bbf\u95ee\u6570\u7ec4\u7684\u4e0d\u540c\u6574\u6570\u4f4d\u7f6e\uff0c\u4e0b\u9762\u901a\u8fc7\u5faa\u73af\u6765\u7ed9\u65b0\u5206\u914d\u7684\u6570\u7ec4\u7684\u6bcf\u4e2a\u5143\u7d20\u90fd\u521d\u59cb\u5316\u4e3a0\u3002<\/p>\n<pre class=\"lang:default decode:true\">int *pi2, i;\n...\npi2 = pi;\nfor(i = 0; i &lt; 25; i++)\n    *pi2++ = 0;<\/pre>\n<p>\u6211\u4eec\u4e5f\u53ef\u4ee5\u4f7f\u7528\u6570\u7ec4\u4e0b\u6807\u6765\u8fdb\u884c\u64cd\u4f5c\uff1a<\/p>\n<pre class=\"lang:default decode:true\">int i;\n...\nfor(i=0; i&lt;25; i++)\n    pi[i] = 0;<\/pre>\n<h6>\u56db\u3001\u5e38\u89c1\u7684\u52a8\u6001\u5185\u5b58\u9519\u8bef<\/h6>\n<p>1.\u4f7f\u7528\u52a8\u6001\u5185\u5b58\u5206\u914d\u7684\u7a0b\u5e8f\u4e2d\uff0c\u5e38\u5e38\u4f1a\u51fa\u73b0\u5f88\u591a\u9519\u8bef\u3002<br \/>\n1&gt;\u5bf9NULL\u6307\u9488\u8fdb\u884c\u89e3\u5f15\u7528\u64cd\u4f5c<br \/>\n2&gt;\u5bf9\u5206\u914d\u7684\u5185\u5b58\u8fdb\u884c\u64cd\u4f5c\u65f6\u8d8a\u8fc7\u8fb9\u754c<br \/>\n3&gt;\u91ca\u653e\u5e76\u975e\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58<br \/>\n4&gt;\u8bd5\u56fe\u91ca\u653e\u4e00\u5757\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u7684\u4e00\u90e8\u5206\u4ee5\u53ca\u4e00\u5757\u5185\u5b58\u88ab\u91ca\u653e\u4e4b\u540e\u88ab\u7ee7\u7eed\u4f7f\u7528\u3002<br \/>\n\u8bf4\u660e\uff1a<br \/>\n<span style=\"color: #ff0000;\">\u52a8\u6001\u5206\u914d\u6700\u5e38\u89c1\u7684\u9519\u8bef\u5c31\u662f\u5fd8\u8bb0\u68c0\u67e5\u6240\u8bf7\u6c42\u7684\u5185\u5b58\u662f\u5426\u6210\u529f\u5206\u914d<\/span>\u3002<br \/>\n<span style=\"color: #ff0000;\">\u52a8\u6001\u5185\u5b58\u5206\u914d\u7684\u7b2c\u4e8c\u5927\u9519\u8bef\u6765\u6e90\u662f\u64cd\u4f5c\u5185\u5b58\u65f6\u8d85\u51fa\u4e86\u5206\u914d\u5185\u5b58\u7684\u8fb9\u754c<\/span>\u3002<\/p>\n<p>2.\u5f53\u4f60\u4f7f\u7528free\u65f6\uff0c\u53ef\u80fd\u51fa\u73b0\u5404\u79cd\u4e0d\u540c\u7684\u9519\u8bef\u3002<br \/>\n1&gt;<strong><span style=\"color: #ff0000;\">\u4f20\u9012\u7ed9free\u7684\u6307\u9488\u5fc5\u987b\u662f\u4e00\u4e2a\u4ecemalloc\u3001calloc\u6216realloc\u51fd\u6570\u8fd4\u56de\u7684\u6307\u9488<\/span><\/strong>\u3002<br \/>\n2&gt;\u4f20\u9012\u7ed9free\u51fd\u6570\u4e00\u4e2a\u6307\u9488\uff0c\u8ba9\u5b83\u91ca\u653e\u4e00\u5757\u5e76\u975e\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u53ef\u80fd\u5bfc\u81f4\u7a0b\u5e8f\u7acb\u5373\u7ec8\u6b62\u6216\u5728\u665a\u4e9b\u65f6\u5019\u7ec8\u6b62\u3002<br \/>\n3&gt;\u8bd5\u56fe\u91ca\u653e\u4e00\u5757\u52a8\u6001\u5206\u914d\u5185\u5b58\u7684\u4e00\u90e8\u5206\u4e5f\u6709\u53ef\u80fd\u5f15\u8d77\u7c7b\u4f3c\u95ee\u9898\uff0c\u6bd4\u5982\uff1a<\/p>\n<pre class=\"lang:default decode:true\">\/**\n***Get 10 integers' memory space\n**\/\npi = malloc(10*sizeof(int));\n...\n\/*\n**\u4ec5\u91ca\u653e\u540e5\u4e2a\u6574\u6570\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u524d\u9762\u76845\u4e2a\u6570\u4e0d\u91ca\u653e\n*\/\nfree(pi + 5);<\/pre>\n<p>\u8bf4\u660e\uff1a<br \/>\n<span style=\"color: #ff0000;\">\u91ca\u653e\u4e00\u5757\u5185\u5b58\u7684\u4e00\u90e8\u5206\u662f\u4e0d\u5141\u8bb8\u7684\u3002\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u5fc5\u987b\u6574\u5757\u4e00\u8d77\u91ca\u653e\u3002<\/span>\u4f46\u662f\uff0crealloc\u51fd\u6570\u53ef\u4ee5\u7f29\u5c0f\u4e00\u5757\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\uff0c\u6709\u6548\u5730\u91ca\u653e\u5b83\u5c3e\u90e8\u7684\u90e8\u5206\u5185\u5b58\u3002<br \/>\n4&gt;<span style=\"color: #ff0000;\"><strong>\u4e0d\u8981\u8bbf\u95ee\u5df2\u7ecf\u88abfree\u51fd\u6570\u91ca\u653e\u4e86\u7684\u5185\u5b58<\/strong><\/span>\u3002\u5047\u5b9a\u5bf9\u4e00\u4e2a\u6307\u5411\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u7684\u6307\u9488\u8fdb\u884c\u4e86\u590d\u5236\uff0c\u800c\u4e14\u8fd9\u4e2a\u6307\u9488\u7684\u51e0\u4efd\u62f7\u8d1d\u5206\u6563\u4e8e\u7a0b\u5e8f\u5404\u5904\u3002\u4f60\u65e0\u6cd5\u4fdd\u8bc1\u5f53\u4f60\u4f7f\u7528\u5176\u4e2d\u4e00\u4e2a\u6307\u9488\u65f6\u5b83\u6240\u6307\u5411\u7684\u5185\u5b58\u662f\u4e0d\u662f\u5df2\u88ab\u53e6\u4e00\u4e2a\u6307\u9488\u91ca\u653e\u3002\u8fd8\u8981\u786e\u4fdd\u7a0b\u5e8f\u4e2d\u6240\u6709\u4f7f\u7528\u8fd9\u5757\u5185\u5b58\u7684\u5730\u65b9\u5728\u8fd9\u5757\u5185\u5b58\u91ca\u653e\u4e4b\u524d\u505c\u6b62\u5bf9\u5b83\u7684\u4f7f\u7528\u3002<br \/>\n5&gt;\u5f53\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u4e0d\u518d\u9700\u8981\u4f7f\u7528\u65f6\uff0c\u5e94\u8be5\u88ab\u91ca\u653e\uff0c\u8fd9\u6837\u8be5\u5185\u5b58\u7a7a\u95f4\u5c31\u53ef\u4ee5\u88ab\u91cd\u65b0\u5206\u914d\u4f7f\u7528\u3002\u5206\u914d\u5185\u5b58\u4f46\u5728\u4f7f\u7528\u5b8c\u6bd5\u540e\u4e0d\u91ca\u653e\u5c06\u5f15\u8d77\u5185\u5b58\u6cc4\u6f0f(memory leak)\u3002<\/p>\n<h6>\u603b\u7ed3\uff1a<\/h6>\n<p>1.\u5f53\u6570\u7ec4\u88ab\u58f0\u660e\u65f6\uff0c\u5fc5\u987b\u5728<span style=\"color: #ff0000;\">\u7f16\u8bd1\u65f6<\/span>\u77e5\u9053\u5b83\u7684\u957f\u5ea6\u3002\u52a8\u6001\u5185\u5b58\u5206\u914d\u5141\u8bb8\u7a0b\u5e8f\u4e3a\u4e00\u4e2a\u957f\u5ea6\u5728<span style=\"color: #ff0000;\">\u8fd0\u884c\u65f6<\/span>\u624d\u77e5\u9053\u7684\u6570\u7ec4\u5206\u914d\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n<p>2.malloc\u548ccalloc\u51fd\u6570\u90fd\u7528\u4e8e\u52a8\u6001\u5206\u914d\u4e00\u5757\u5185\u5b58\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u6307\u5b9a\u8be5\u5757\u5185\u5b58\u7684\u6307\u9488\u3002<br \/>\n1&gt;malloc\u7684\u53c2\u6570\u5c31\u662f\u9700\u8981\u5206\u914d\u7684\u5185\u5b58\u7684\u5b57\u8282\u6570\u3002<br \/>\n2&gt;calloc\u7684\u53c2\u6570\u662f\u9700\u8981\u5206\u914d\u7684\u5143\u7d20\u4e2a\u6570\u548c\u6bcf\u4e2a\u5143\u7d20\u7684\u957f\u5ea6\u3002<span style=\"color: #ff0000;\">calloc\u51fd\u6570\u5728\u8fd4\u56de\u524d\u628a\u5185\u5b58\u521d\u59cb\u5316\u4e3a\u96f6\u3002<\/span>malloc\u51fd\u6570\u8fd4\u56de\u65f6\u5185\u5b58\u5e76\u672a\u4ee5\u4efb\u4f55\u65b9\u5f0f\u8fdb\u884c\u521d\u59cb\u5316\u3002<br \/>\n3&gt;\u8c03\u7528realloc\u51fd\u6570\u53ef\u4ee5\u6539\u53d8\u4e00\u5757\u5df2\u7ecf\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u7684\u5927\u5c0f\u3002\u589e\u52a0\u5185\u5b58\u5757\u5927\u5c0f\u6709\u65f6\u6709\u53ef\u80fd\u91c7\u53d6\u7684\u65b9\u6cd5\u662f\u628a\u539f\u6765\u5185\u5b58\u5757\u4e0a\u7684\u6240\u6709\u6570\u636e\u590d\u5236\u5230\u4e00\u4e2a\u65b0\u7684\u3001\u66f4\u5927\u7684\u5185\u5b58\u5757\u4e0a\u3002\u5f53\u4e00\u4e2a\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u5757\u4e0d\u518d\u4f7f\u7528\u65f6\uff0c\u5e94\u8be5\u8c03\u7528free\u51fd\u6570\u628a\u5b83\u5f52\u8fd8\u7ed9\u53ef\u7528\u5185\u5b58\u6c60\uff0c\u5185\u5b58\u91ca\u653e\u540e\u5c31\u4e0d\u80fd\u518d\u88ab\u8bbf\u95ee\u3002<\/p>\n<p>3.\u5982\u679c\u8bf7\u6c42\u7684\u5185\u5b58\u5206\u914d\u5931\u8d25\uff0cmalloc\u3001alloc\u548crealloc\u51fd\u6570\u8fd4\u56de\u7684\u5c06\u662f\u4e00\u4e2aNULL\u6307\u9488\u3002<\/p>\n<p>4.\u9519\u8bef\u7684\u8bbf\u95ee\u5206\u914d\u5185\u5b58\u4e4b\u5916\u7684\u533a\u57df\u6240\u5f15\u8d77\u7684\u540e\u679c\u7c7b\u4f3c\u8d8a\u754c\u8bbf\u95ee\u4e00\u4e2a\u6570\u7ec4\uff0c\u800c\u4e14\u8fd9\u4e2a\u9519\u8bef\u8fd8\u80fd\u7834\u574f\u53ef\u7528\u5185\u5b58\u6c60\uff0c\u5bfc\u81f4\u7a0b\u5e8f\u5931\u8d25\u3002<\/p>\n<p>5.\u5982\u679c\u4e00\u4e2a\u6307\u9488\u4e0d\u662f\u4ece\u65e9\u5148\u7684malloc\u3001calloc\u6216realloc\u51fd\u6570\u8fd4\u56de\u7684\uff0c\u5b83\u662f\u4e0d\u80fd\u4f5c\u4e3a\u53c2\u6570\u4f20\u9012\u7ed9free\u51fd\u6570\u7684\uff08\u5373\uff0c<span style=\"color: #ff0000;\">malloc|alloc|realloc\u548cfree\u662f\u9700\u8981\u4e00\u4e00\u5bf9\u5e94\u7684<\/span>\uff09\u3002<\/p>\n<p>\u539f\u6587\u5730\u5740\uff1a<a href=\"http:\/\/blog.csdn.net\/tigerjibo\/article\/details\/7226611\" target=\"_blank\">\u52a8\u6001\u5185\u5b58\u5206\u914d &#8211; \u5180\u535a<\/a><\/p>\n<p>***********************************************************<\/p>\n<p>\u540e\u6765\u5728\u4f2f\u4e50\u5728\u7ebf\u4e0a\u6709\u770b\u5230\u4e86\u4e00\u7bc7\u8bb2\u7684\u975e\u5e38\u7ecf\u5178\u7684\u6587\u7ae0\uff1a<a href=\"http:\/\/blog.jobbole.com\/75321\/\" target=\"_blank\">\u4ec0\u4e48\u662f\u5806\u548c\u6808\uff0c\u5b83\u4eec\u5728\u54ea\u513f\uff1f<\/a>\uff0c\u5fcd\u4e0d\u4f4f\u4e5f\u8f6c\u8f7d\u5176\u5185\u5bb9\u653e\u5728\u4e0b\u9762\u4e86\uff1a<\/p>\n<h5>\u95ee\u9898\u63cf\u8ff0<\/h5>\n<p>\u7f16\u7a0b\u8bed\u8a00\u4e66\u7c4d\u4e2d\u7ecf\u5e38\u89e3\u91ca\u503c\u7c7b\u578b\u88ab\u521b\u5efa\u5728\u6808\u4e0a\uff0c\u5f15\u7528\u7c7b\u578b\u88ab\u521b\u5efa\u5728\u5806\u4e0a\uff0c\u4f46\u662f\u5e76\u6ca1\u6709\u672c\u8d28\u4e0a\u89e3\u91ca\u8fd9\u5806\u548c\u6808\u662f\u4ec0\u4e48\u3002\u6211\u4ec5\u6709\u9ad8\u7ea7\u8bed\u8a00\u7f16\u7a0b\u7ecf\u9a8c\uff0c\u6ca1\u6709\u770b\u8fc7\u5bf9\u6b64\u66f4\u6e05\u6670\u7684\u89e3\u91ca\u3002\u6211\u7684\u610f\u601d\u662f\u6211\u7406\u89e3\u4ec0\u4e48\u662f\u6808\uff0c\u4f46\u662f\u5b83\u4eec\u5230\u5e95\u662f\u4ec0\u4e48\uff0c\u5728\u54ea\u513f\u5462\uff08\u7ad9\u5728\u5b9e\u9645\u7684\u8ba1\u7b97\u673a\u7269\u7406\u5185\u5b58\u7684\u89d2\u5ea6\u4e0a\u770b\uff09\uff1f<\/p>\n<ol>\n<ol>\n<li>\u5728\u901a\u5e38\u60c5\u51b5\u4e0b\u7531\u64cd\u4f5c\u7cfb\u7edf\uff08OS\uff09\u548c\u8bed\u8a00\u7684\u8fd0\u884c\u65f6\uff08runtime\uff09\u63a7\u5236\u5417\uff1f<\/li>\n<li>\u5b83\u4eec\u7684\u4f5c\u7528\u8303\u56f4\u662f\u4ec0\u4e48\uff1f<\/li>\n<li>\u5b83\u4eec\u7684\u5927\u5c0f\u7531\u4ec0\u4e48\u51b3\u5b9a\uff1f<\/li>\n<li>\u54ea\u4e2a\u66f4\u5feb\uff1f<\/li>\n<\/ol>\n<\/ol>\n<h5>\u7b54\u6848\u4e00<\/h5>\n<p>\u6808\u662f\u4e3a\u6267\u884c\u7ebf\u7a0b\u7559\u51fa\u7684\u5185\u5b58\u7a7a\u95f4\u3002\u5f53\u51fd\u6570\u88ab\u8c03\u7528\u7684\u65f6\u5019\uff0c\u6808\u9876\u4e3a\u5c40\u90e8\u53d8\u91cf\u548c\u4e00\u4e9b bookkeeping \u6570\u636e\u9884\u7559\u5757\u3002\u5f53\u51fd\u6570\u6267\u884c\u5b8c\u6bd5\uff0c\u5757\u5c31\u6ca1\u6709\u7528\u4e86\uff0c\u53ef\u80fd\u5728\u4e0b\u6b21\u7684\u51fd\u6570\u8c03\u7528\u7684\u65f6\u5019\u518d\u88ab\u4f7f\u7528\u3002\u6808\u901a\u5e38\u7528\u540e\u8fdb\u5148\u51fa\uff08LIFO\uff09\u7684\u65b9\u5f0f\u9884\u7559\u7a7a\u95f4\uff1b\u56e0\u6b64\u6700\u8fd1\u7684\u4fdd\u7559\u5757\uff08reserved block\uff09\u901a\u5e38\u6700\u5148\u88ab\u91ca\u653e\u3002\u8fd9\u4e48\u505a\u53ef\u4ee5\u4f7f\u8ddf\u8e2a\u5806\u6808\u53d8\u7684\u7b80\u5355\uff1b\u4ece\u6808\u4e2d\u91ca\u653e\u5757\uff08free block\uff09\u53ea\u4e0d\u8fc7\u662f\u6307\u9488\u7684\u504f\u79fb\u800c\u5df2\u3002<\/p>\n<p>\u5806\uff08heap\uff09\u662f\u4e3a\u52a8\u6001\u5206\u914d\u9884\u7559\u7684\u5185\u5b58\u7a7a\u95f4\u3002\u548c\u6808\u4e0d\u4e00\u6837\uff0c\u4ece\u5806\u4e0a\u5206\u914d\u548c\u91cd\u65b0\u5206\u914d\u5757\u6ca1\u6709\u56fa\u5b9a\u6a21\u5f0f\uff1b\u4f60\u53ef\u4ee5\u5728\u4efb\u4f55\u65f6\u5019\u5206\u914d\u548c\u91ca\u653e\u5b83\u3002\u8fd9\u6837\u4f7f\u5f97\u8ddf\u8e2a\u54ea\u90e8\u5206\u5806\u5df2\u7ecf\u88ab\u5206\u914d\u548c\u88ab\u91ca\u653e\u53d8\u7684\u5f02\u5e38\u590d\u6742\uff1b\u6709\u8bb8\u591a\u5b9a\u5236\u7684\u5806\u5206\u914d\u7b56\u7565\u7528\u6765\u4e3a\u4e0d\u540c\u7684\u4f7f\u7528\u6a21\u5f0f\u4e0b\u8c03\u6574\u5806\u7684\u6027\u80fd\u3002<\/p>\n<p>\u6bcf\u4e00\u4e2a\u7ebf\u7a0b\u90fd\u6709\u4e00\u4e2a\u6808\uff0c\u4f46\u662f\u6bcf\u4e00\u4e2a\u5e94\u7528\u7a0b\u5e8f\u901a\u5e38\u90fd\u53ea\u6709\u4e00\u4e2a\u5806\uff08\u5c3d\u7ba1\u4e3a\u4e0d\u540c\u7c7b\u578b\u5206\u914d\u5185\u5b58\u4f7f\u7528\u591a\u4e2a\u5806\u7684\u60c5\u51b5\u4e5f\u662f\u6709\u7684\uff09\u3002<\/p>\n<p>\u76f4\u63a5\u56de\u7b54\u4f60\u7684\u95ee\u9898\uff1a 1. \u5f53\u7ebf\u7a0b\u521b\u5efa\u7684\u65f6\u5019\uff0c\u64cd\u4f5c\u7cfb\u7edf\uff08OS\uff09\u4e3a\u6bcf\u4e00\u4e2a\u7cfb\u7edf\u7ea7\uff08system-level\uff09\u7684\u7ebf\u7a0b\u5206\u914d\u6808\u3002\u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u64cd\u4f5c\u7cfb\u7edf\u901a\u8fc7\u8c03\u7528\u8bed\u8a00\u7684\u8fd0\u884c\u65f6\uff08runtime\uff09\u53bb\u4e3a\u5e94\u7528\u7a0b\u5e8f\u5206\u914d\u5806\u3002 2. \u6808\u9644\u5c5e\u4e8e\u7ebf\u7a0b\uff0c\u56e0\u6b64\u5f53\u7ebf\u7a0b\u7ed3\u675f\u65f6\u6808\u88ab\u56de\u6536\u3002\u5806\u901a\u5e38\u901a\u8fc7\u8fd0\u884c\u65f6\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u65f6\u88ab\u5206\u914d\uff0c\u5f53\u5e94\u7528\u7a0b\u5e8f\uff08\u8fdb\u7a0b\uff09\u9000\u51fa\u65f6\u88ab\u56de\u6536\u3002 3. \u5f53\u7ebf\u7a0b\u88ab\u521b\u5efa\u7684\u65f6\u5019\uff0c\u8bbe\u7f6e\u6808\u7684\u5927\u5c0f\u3002\u5728\u5e94\u7528\u7a0b\u5e8f\u542f\u52a8\u7684\u65f6\u5019\uff0c\u8bbe\u7f6e\u5806\u7684\u5927\u5c0f\uff0c\u4f46\u662f\u53ef\u4ee5\u5728\u9700\u8981\u7684\u65f6\u5019\u6269\u5c55\uff08\u5206\u914d\u5668\u5411\u64cd\u4f5c\u7cfb\u7edf\u7533\u8bf7\u66f4\u591a\u7684\u5185\u5b58\uff09\u3002 4. \u6808\u6bd4\u5806\u8981\u5feb\uff0c\u56e0\u4e3a\u5b83\u5b58\u53d6\u6a21\u5f0f\u4f7f\u5b83\u53ef\u4ee5\u8f7b\u677e\u7684\u5206\u914d\u548c\u91cd\u65b0\u5206\u914d\u5185\u5b58\uff08\u6307\u9488\/\u6574\u578b\u53ea\u662f\u8fdb\u884c\u7b80\u5355\u7684\u9012\u589e\u6216\u8005\u9012\u51cf\u8fd0\u7b97\uff09\uff0c\u7136\u800c\u5806\u5728\u5206\u914d\u548c\u91ca\u653e\u7684\u65f6\u5019\u6709\u66f4\u591a\u7684\u590d\u6742\u7684 bookkeeping \u53c2\u4e0e\u3002\u53e6\u5916\uff0c\u5728\u6808\u4e0a\u7684\u6bcf\u4e2a\u5b57\u8282\u9891\u7e41\u7684\u88ab\u590d\u7528\u4e5f\u5c31\u610f\u5473\u7740\u5b83\u53ef\u80fd\u6620\u5c04\u5230\u5904\u7406\u5668\u7f13\u5b58\u4e2d\uff0c\u6240\u4ee5\u5f88\u5feb\uff08\u8bd1\u8005\u6ce8\uff1a\u5c40\u90e8\u6027\u539f\u7406\uff09\u3002<\/p>\n<h5>\u7b54\u6848\u4e8c<\/h5>\n<h6>Stack<\/h6>\n<ol>\n<ol>\n<li>\u548c\u5806\u4e00\u6837\u5b58\u50a8\u5728\u8ba1\u7b97\u673a RAM \u4e2d\u3002<\/li>\n<li>\u5728\u6808\u4e0a\u521b\u5efa\u53d8\u91cf\u7684\u65f6\u5019\u4f1a\u6269\u5c55\uff0c\u5e76\u4e14\u4f1a\u81ea\u52a8\u56de\u6536\u3002<\/li>\n<li>\u76f8\u6bd4\u5806\u800c\u8a00\u5728\u6808\u4e0a\u5206\u914d\u8981\u5feb\u7684\u591a\u3002<\/li>\n<li>\u7528\u6570\u636e\u7ed3\u6784\u4e2d\u7684\u6808\u5b9e\u73b0\u3002<\/li>\n<li>\u5b58\u50a8\u5c40\u90e8\u6570\u636e\uff0c\u8fd4\u56de\u5730\u5740\uff0c\u7528\u505a\u53c2\u6570\u4f20\u9012\u3002<\/li>\n<li>\u5f53\u7528\u6808\u8fc7\u591a\u65f6\u53ef\u5bfc\u81f4\u6808\u6ea2\u51fa\uff08\u65e0\u7a77\u6b21\uff08\u5927\u91cf\u7684\uff09\u7684\u9012\u5f52\u8c03\u7528\uff0c\u6216\u8005\u5927\u91cf\u7684\u5185\u5b58\u5206\u914d\uff09\u3002<\/li>\n<li>\u5728\u6808\u4e0a\u7684\u6570\u636e\u53ef\u4ee5\u76f4\u63a5\u8bbf\u95ee\uff08\u4e0d\u662f\u975e\u8981\u4f7f\u7528\u6307\u9488\u8bbf\u95ee\uff09\u3002<\/li>\n<li>\u5982\u679c\u4f60\u5728\u7f16\u8bd1\u4e4b\u524d\u7cbe\u786e\u7684\u77e5\u9053\u4f60\u9700\u8981\u5206\u914d\u6570\u636e\u7684\u5927\u5c0f\u5e76\u4e14\u4e0d\u662f\u592a\u5927\u7684\u65f6\u5019\uff0c\u53ef\u4ee5\u4f7f\u7528\u6808\u3002<\/li>\n<li>\u5f53\u4f60\u7a0b\u5e8f\u542f\u52a8\u65f6\u51b3\u5b9a\u6808\u7684\u5bb9\u91cf\u4e0a\u9650\u3002<\/li>\n<\/ol>\n<\/ol>\n<h6>Heap<\/h6>\n<ol>\n<ol>\n<li>\u548c\u6808\u4e00\u6837\u5b58\u50a8\u5728\u8ba1\u7b97\u673aRAM\u3002<\/li>\n<li>\u5728\u5806\u4e0a\u7684\u53d8\u91cf\u5fc5\u987b\u8981\u624b\u52a8\u91ca\u653e\uff0c\u4e0d\u5b58\u5728\u4f5c\u7528\u57df\u7684\u95ee\u9898\u3002\u6570\u636e\u53ef\u7528 delete, delete[] \u6216\u8005 free \u6765\u91ca\u653e\u3002<\/li>\n<li>\u76f8\u6bd4\u5728\u6808\u4e0a\u5206\u914d\u5185\u5b58\u8981\u6162\u3002<\/li>\n<li>\u901a\u8fc7\u7a0b\u5e8f\u6309\u9700\u5206\u914d\u3002<\/li>\n<li>\u5927\u91cf\u7684\u5206\u914d\u548c\u91ca\u653e\u53ef\u9020\u6210\u5185\u5b58\u788e\u7247\u3002<\/li>\n<li>\u5728 C++ \u4e2d\uff0c\u5728\u5806\u4e0a\u521b\u5efa\u6570\u7684\u636e\u4f7f\u7528\u6307\u9488\u8bbf\u95ee\uff0c\u7528 new \u6216\u8005 malloc \u5206\u914d\u5185\u5b58\u3002<\/li>\n<li>\u5982\u679c\u7533\u8bf7\u7684\u7f13\u51b2\u533a\u8fc7\u5927\u7684\u8bdd\uff0c\u53ef\u80fd\u7533\u8bf7\u5931\u8d25\u3002<\/li>\n<li>\u5728\u8fd0\u884c\u671f\u95f4\u4f60\u4e0d\u77e5\u9053\u4f1a\u9700\u8981\u591a\u5927\u7684\u6570\u636e\u6216\u8005\u4f60\u9700\u8981\u5206\u914d\u5927\u91cf\u7684\u5185\u5b58\u7684\u65f6\u5019\uff0c\u5efa\u8bae\u4f60\u4f7f\u7528\u5806\u3002<\/li>\n<li>\u53ef\u80fd\u9020\u6210\u5185\u5b58\u6cc4\u9732\u3002<\/li>\n<\/ol>\n<\/ol>\n<p>\u4e3e\u4f8b\uff1a<\/p>\n<pre class=\"lang:default decode:true\">int foo()\n{\n    char *pBuffer; \/\/&lt;--nothing allocated yet (excluding the pointer itself, which is allocated here on the stack).\n    bool b = true; \/\/ Allocated on the stack.\n    if(b)\n    {\n        \/\/Create 500 bytes on the stack\n        char buffer[500];\n\n        \/\/Create 500 bytes on the heap\n        pBuffer = new char[500];\n\n    }\/\/&lt;-- buffer is deallocated here, pBuffer is not\n}\/\/&lt;--- oops there's a memory leak, I should have called delete[] pBuffer;<\/pre>\n<h5>\u7b54\u6848\u4e09<\/h5>\n<p>\u5806\u548c\u6808\u662f\u4e24\u79cd\u5185\u5b58\u5206\u914d\u7684\u4e24\u4e2a\u7edf\u79f0\u3002\u53ef\u80fd\u6709\u5f88\u591a\u79cd\u4e0d\u540c\u7684\u5b9e\u73b0\u65b9\u5f0f\uff0c\u4f46\u662f\u5b9e\u73b0\u8981\u7b26\u5408\u51e0\u4e2a\u57fa\u672c\u7684\u6982\u5ff5:<\/p>\n<p>1.\u5bf9\u6808\u800c\u8a00\uff0c\u6808\u4e2d\u7684\u65b0\u52a0\u6570\u636e\u9879\u653e\u5728\u5176\u4ed6\u6570\u636e\u7684\u9876\u90e8\uff0c\u79fb\u9664\u65f6\u4f60\u4e5f\u53ea\u80fd\u79fb\u9664\u6700\u9876\u90e8\u7684\u6570\u636e\uff08\u4e0d\u80fd\u8d8a\u4f4d\u83b7\u53d6\uff09\u3002<\/p>\n<p><a href=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/08\/stack.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1110\" src=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/08\/stack.jpg\" alt=\"stack\" width=\"255\" height=\"282\" \/><\/a><\/p>\n<p>2.\u5bf9\u5806\u800c\u8a00\uff0c\u6570\u636e\u9879\u4f4d\u7f6e\u6ca1\u6709\u56fa\u5b9a\u7684\u987a\u5e8f\u3002\u4f60\u53ef\u4ee5\u4ee5\u4efb\u4f55\u987a\u5e8f\u63d2\u5165\u548c\u5220\u9664\uff0c\u56e0\u4e3a\u4ed6\u4eec\u6ca1\u6709\u201c\u9876\u90e8\u201d\u6570\u636e\u8fd9\u4e00\u6982\u5ff5\u3002<\/p>\n<p><a href=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/08\/heap.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-1111\" src=\"http:\/\/ixyzero.com\/blog\/wp-content\/uploads\/2014\/08\/heap.jpg\" alt=\"heap\" width=\"160\" height=\"120\" \/><\/a><\/p>\n<p>\u4e0a\u9762\u4e24\u4e2a\u56fe\u7247\u5f88\u597d\u7684\u63cf\u8ff0\u4e86\u5806\u548c\u6808\u5206\u914d\u5185\u5b58\u7684\u65b9\u5f0f\u3002<\/p>\n<h6>\u5728\u901a\u5e38\u60c5\u51b5\u4e0b\u7531\u64cd\u4f5c\u7cfb\u7edf\uff08OS\uff09\u548c\u8bed\u8a00\u7684\u8fd0\u884c\u65f6\uff08runtime\uff09\u63a7\u5236\u5417\uff1f<\/h6>\n<p>\u5982\u524d\u6240\u8ff0\uff0c\u5806\u548c\u6808\u662f\u4e00\u4e2a\u7edf\u79f0\uff0c\u53ef\u4ee5\u6709\u5f88\u591a\u7684\u5b9e\u73b0\u65b9\u5f0f\u3002\u8ba1\u7b97\u673a\u7a0b\u5e8f\u901a\u5e38\u6709\u4e00\u4e2a\u6808\u53eb\u505a\u8c03\u7528\u6808\uff0c\u7528\u6765\u5b58\u50a8\u5f53\u524d\u51fd\u6570\u8c03\u7528\u76f8\u5173\u7684\u4fe1\u606f\uff08\u6bd4\u5982\uff1a\u4e3b\u8c03\u51fd\u6570\u7684\u5730\u5740\uff0c\u5c40\u90e8\u53d8\u91cf\uff09\uff0c\u56e0\u4e3a\u51fd\u6570\u8c03\u7528\u4e4b\u540e\u9700\u8981\u8fd4\u56de\u7ed9\u4e3b\u8c03\u51fd\u6570\u3002\u6808\u901a\u8fc7\u6269\u5c55\u548c\u6536\u7f29\u6765\u627f\u8f7d\u4fe1\u606f\u3002\u5b9e\u9645\u4e0a\uff0c\u7a0b\u5e8f\u4e0d\u662f\u7531\u8fd0\u884c\u65f6\u6765\u63a7\u5236\u7684\uff0c\u5b83\u7531\u7f16\u7a0b\u8bed\u8a00\u3001\u64cd\u4f5c\u7cfb\u7edf\u751a\u81f3\u662f\u7cfb\u7edf\u67b6\u6784\u6765\u51b3\u5b9a\u3002<\/p>\n<p>\u5806\u662f\u5728\u4efb\u4f55\u5185\u5b58\u4e2d\u52a8\u6001\u548c\u968f\u673a\u5206\u914d\u7684\uff08\u5185\u5b58\u7684\uff09\u7edf\u79f0\uff1b\u4e5f\u5c31\u662f\u65e0\u5e8f\u7684\u3002\u5185\u5b58\u901a\u5e38\u7531\u64cd\u4f5c\u7cfb\u7edf\u5206\u914d\uff0c\u901a\u8fc7\u5e94\u7528\u7a0b\u5e8f\u8c03\u7528 API \u63a5\u53e3\u53bb\u5b9e\u73b0\u5206\u914d\u3002\u5728\u7ba1\u7406\u52a8\u6001\u5206\u914d\u5185\u5b58\u4e0a\u4f1a\u6709\u4e00\u4e9b\u989d\u5916\u7684\u5f00\u9500\uff0c\u4e0d\u8fc7\u8fd9\u7531\u64cd\u4f5c\u7cfb\u7edf\u6765\u5904\u7406\u3002<\/p>\n<h6>\u5b83\u4eec\u7684\u4f5c\u7528\u8303\u56f4\u662f\u4ec0\u4e48\uff1f<\/h6>\n<p>\u8c03\u7528\u6808\u662f\u4e00\u4e2a\u4f4e\u5c42\u6b21\u7684\u6982\u5ff5\uff0c\u5c31\u7a0b\u5e8f\u800c\u8a00\uff0c\u5b83\u548c\u201c\u4f5c\u7528\u8303\u56f4\u201d\u6ca1\u4ec0\u4e48\u5173\u7cfb\u3002\u5982\u679c\u4f60\u53cd\u6c47\u7f16\u4e00\u4e9b\u4ee3\u7801\uff0c\u4f60\u5c31\u4f1a\u770b\u5230\u6307\u9488\u5f15\u7528\u5806\u6808\u90e8\u5206\u3002\u5c31\u9ad8\u7ea7\u8bed\u8a00\u800c\u8a00\uff0c\u8bed\u8a00\u6709\u5b83\u81ea\u5df1\u7684\u8303\u56f4\u89c4\u5219\u3002\u4e00\u65e6\u51fd\u6570\u8fd4\u56de\uff0c\u51fd\u6570\u4e2d\u7684\u5c40\u90e8\u53d8\u91cf\u4f1a\u76f4\u63a5\u76f4\u63a5\u91ca\u653e\u3002\u4f60\u7684\u7f16\u7a0b\u8bed\u8a00\u5c31\u662f\u4f9d\u636e\u8fd9\u4e2a\u5de5\u4f5c\u7684\u3002<\/p>\n<p>\u5728\u5806\u4e2d\uff0c\u4e5f\u5f88\u96be\u53bb\u5b9a\u4e49\u3002\u4f5c\u7528\u8303\u56f4\u662f\u7531\u64cd\u4f5c\u7cfb\u7edf\u9650\u5b9a\u7684\uff0c\u4f46\u662f\u4f60\u7684\u7f16\u7a0b\u8bed\u8a00\u53ef\u80fd\u589e\u52a0\u5b83\u81ea\u5df1\u7684\u4e00\u4e9b\u89c4\u5219\uff0c\u53bb\u9650\u5b9a\u5806\u5728\u5e94\u7528\u7a0b\u5e8f\u4e2d\u7684\u8303\u56f4\u3002\u4f53\u7cfb\u67b6\u6784\u548c\u64cd\u4f5c\u7cfb\u7edf\u662f\u4f7f\u7528\u865a\u62df\u5730\u5740\u7684\uff0c\u7136\u540e\u7531\u5904\u7406\u5668\u7ffb\u8bd1\u5230\u5b9e\u9645\u7684\u7269\u7406\u5730\u5740\u4e2d\uff0c\u8fd8\u6709\u9875\u9762\u9519\u8bef\u7b49\u7b49\u3002\u5b83\u4eec\u8bb0\u5f55\u90a3\u4e2a\u9875\u9762\u5c5e\u4e8e\u90a3\u4e2a\u5e94\u7528\u7a0b\u5e8f\u3002\u4e0d\u8fc7\u4f60\u4e0d\u7528\u5173\u5fc3\u8fd9\u4e9b\uff0c\u56e0\u4e3a\u4f60\u4ec5\u4ec5\u5728\u4f60\u7684\u7f16\u7a0b\u8bed\u8a00\u4e2d\u5206\u914d\u548c\u91ca\u653e\u5185\u5b58\uff0c\u548c\u4e00\u4e9b\u9519\u8bef\u68c0\u67e5\uff08\u51fa\u73b0\u5206\u914d\u5931\u8d25\u548c\u91ca\u653e\u5931\u8d25\u7684\u539f\u56e0\uff09\u3002<\/p>\n<h6>\u5b83\u4eec\u7684\u5927\u5c0f\u7531\u4ec0\u4e48\u51b3\u5b9a\uff1f<\/h6>\n<p>\u4f9d\u65e7\uff0c\u4f9d\u8d56\u4e8e\u8bed\u8a00\uff0c\u7f16\u8bd1\u5668\uff0c\u64cd\u4f5c\u7cfb\u7edf\u548c\u67b6\u6784\u3002\u6808\u901a\u5e38\u63d0\u524d\u5206\u914d\u597d\u4e86\uff0c\u56e0\u4e3a\u6808\u5fc5\u987b\u662f\u8fde\u7eed\u7684\u5185\u5b58\u5757\u3002\u8bed\u8a00\u7684\u7f16\u8bd1\u5668\u6216\u8005\u64cd\u4f5c\u7cfb\u7edf\u51b3\u5b9a\u5b83\u7684\u5927\u5c0f\u3002\u4e0d\u8981\u5728\u6808\u4e0a\u5b58\u50a8\u5927\u5757\u6570\u636e\uff0c\u8fd9\u6837\u53ef\u4ee5\u4fdd\u8bc1\u6709\u8db3\u591f\u7684\u7a7a\u95f4\u4e0d\u4f1a\u6ea2\u51fa\uff0c\u9664\u975e\u51fa\u73b0\u4e86\u65e0\u9650\u9012\u5f52\u7684\u60c5\u51b5\uff08\u989d\uff0c\u6808\u6ea2\u51fa\u4e86\uff09\u6216\u8005\u5176\u5b83\u4e0d\u5e38\u89c1\u4e86\u7f16\u7a0b\u51b3\u8bae\u3002<\/p>\n<p>\u5806\u662f\u4efb\u4f55\u53ef\u4ee5\u52a8\u6001\u5206\u914d\u7684\u5185\u5b58\u7684\u7edf\u79f0\u3002\u8fd9\u8981\u770b\u4f60\u600e\u4e48\u770b\u5f85\u5b83\u4e86\uff0c\u5b83\u7684\u5927\u5c0f\u662f\u53d8\u52a8\u7684\u3002\u5728\u73b0\u4ee3\u5904\u7406\u5668\u4e2d\u548c\u64cd\u4f5c\u7cfb\u7edf\u7684\u5de5\u4f5c\u65b9\u5f0f\u662f\u9ad8\u5ea6\u62bd\u8c61\u7684\uff0c\u56e0\u6b64\u4f60\u5728\u6b63\u5e38\u60c5\u51b5\u4e0b\u4e0d\u9700\u8981\u62c5\u5fc3\u5b83\u5b9e\u9645\u7684\u5927\u5c0f\uff0c\u9664\u975e\u4f60\u5fc5\u987b\u8981\u4f7f\u7528\u4f60\u8fd8\u6ca1\u6709\u5206\u914d\u7684\u5185\u5b58\u6216\u8005\u5df2\u7ecf\u91ca\u653e\u4e86\u7684\u5185\u5b58\u3002<\/p>\n<h6>\u54ea\u4e2a\u66f4\u5feb\u4e00\u4e9b\uff1f<\/h6>\n<p>\u6808\u66f4\u5feb\u56e0\u4e3a\u6240\u6709\u7684\u7a7a\u95f2\u5185\u5b58\u90fd\u662f\u8fde\u7eed\u7684\uff0c\u56e0\u6b64\u4e0d\u9700\u8981\u5bf9\u7a7a\u95f2\u5185\u5b58\u5757\u901a\u8fc7\u5217\u8868\u6765\u7ef4\u62a4\u3002\u53ea\u662f\u4e00\u4e2a\u7b80\u5355\u7684\u6307\u5411\u5f53\u524d\u6808\u9876\u7684\u6307\u9488\u3002\u7f16\u8bd1\u5668\u901a\u5e38\u7528\u4e00\u4e2a\u4e13\u95e8\u7684\u3001\u5feb\u901f\u7684\u5bc4\u5b58\u5668\u6765\u5b9e\u73b0\u3002\u66f4\u91cd\u8981\u7684\u4e00\u70b9\u4e8b\u662f\uff0c\u968f\u540e\u7684\u6808\u4e0a\u64cd\u4f5c\u901a\u5e38\u96c6\u4e2d\u5728\u4e00\u4e2a\u5185\u5b58\u5757\u7684\u9644\u8fd1\uff0c\u8fd9\u6837\u7684\u8bdd\u6709\u5229\u4e8e\u5904\u7406\u5668\u7684\u9ad8\u901f\u8bbf\u95ee\uff08\u8bd1\u8005\u6ce8\uff1a\u5c40\u90e8\u6027\u539f\u7406\uff09\u3002<\/p>\n<h5>\u7b54\u6848\u56db<\/h5>\n<p>\u4f60\u95ee\u9898\u7684\u7b54\u6848\u662f\u4f9d\u8d56\u4e8e\u5b9e\u73b0\u7684\uff0c\u6839\u636e\u4e0d\u540c\u7684\u7f16\u8bd1\u5668\u548c\u5904\u7406\u5668\u67b6\u6784\u800c\u4e0d\u540c\u3002\u4e0b\u9762\u7b80\u5355\u7684\u89e3\u91ca\u4e00\u4e0b\uff1a<\/p>\n<ol>\n<ol>\n<li>\u6808\u548c\u5806\u90fd\u662f\u7528\u6765\u4ece\u5e95\u5c42\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u83b7\u53d6\u5185\u5b58\u7684\u3002<\/li>\n<li>\u5728\u591a\u7ebf\u7a0b\u73af\u5883\u4e0b\u6bcf\u4e00\u4e2a\u7ebf\u7a0b\u90fd\u53ef\u4ee5\u6709\u4ed6\u81ea\u5df1\u5b8c\u5168\u7684\u72ec\u7acb\u7684\u6808\uff0c\u4f46\u662f\u4ed6\u4eec\u5171\u4eab\u5806\u3002\u5e76\u884c\u5b58\u53d6\u88ab\u5806\u63a7\u5236\u800c\u4e0d\u662f\u6808\u3002<\/li>\n<\/ol>\n<\/ol>\n<h6>\u5806\uff1a<\/h6>\n<ol>\n<ol>\n<li>\u5806\u5305\u542b\u4e00\u4e2a\u94fe\u8868\u6765\u7ef4\u62a4\u5df2\u7528\u548c\u7a7a\u95f2\u7684\u5185\u5b58\u5757\u3002\u5728\u5806\u4e0a\u65b0\u5206\u914d\uff08\u7528 new \u6216\u8005 malloc\uff09\u5185\u5b58\u662f\u4ece\u7a7a\u95f2\u7684\u5185\u5b58\u5757\u4e2d\u627e\u5230\u4e00\u4e9b\u6ee1\u8db3\u8981\u6c42\u7684\u5408\u9002\u5757\u3002\u8fd9\u4e2a\u64cd\u4f5c\u4f1a\u66f4\u65b0\u5806\u4e2d\u7684\u5757\u94fe\u8868\u3002\u8fd9\u4e9b\u5143\u4fe1\u606f\u4e5f\u5b58\u50a8\u5728\u5806\u4e0a\uff0c\u7ecf\u5e38\u5728\u6bcf\u4e2a\u5757\u7684\u5934\u90e8\u4e00\u4e2a\u5f88\u5c0f\u533a\u57df\u3002<\/li>\n<li>\u5806\u7684\u589e\u52a0\u65b0\u5feb\u901a\u5e38\u4ece\u5730\u5730\u5740\u5411\u9ad8\u5730\u5740\u6269\u5c55\u3002\u56e0\u6b64\u4f60\u53ef\u4ee5\u8ba4\u4e3a\u5806\u968f\u7740\u5185\u5b58\u5206\u914d\u800c\u4e0d\u65ad\u7684\u589e\u52a0\u5927\u5c0f\u3002\u5982\u679c\u7533\u8bf7\u7684\u5185\u5b58\u5927\u5c0f\u5f88\u5c0f\u7684\u8bdd\uff0c\u901a\u5e38\u4ece\u5e95\u5c42\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u5f97\u5230\u6bd4\u7533\u8bf7\u5927\u5c0f\u8981\u591a\u7684\u5185\u5b58\u3002<\/li>\n<li>\u7533\u8bf7\u548c\u91ca\u653e\u8bb8\u591a\u5c0f\u7684\u5757\u53ef\u80fd\u4f1a\u4ea7\u751f\u5982\u4e0b\u72b6\u6001\uff1a\u5728\u5df2\u7528\u5757\u4e4b\u95f4\u5b58\u5728\u5f88\u591a\u5c0f\u7684\u7a7a\u95f2\u5757\u3002\u8fdb\u800c\u7533\u8bf7\u5927\u5757\u5185\u5b58\u5931\u8d25\uff0c\u867d\u7136\u7a7a\u95f2\u5757\u7684\u603b\u548c\u8db3\u591f\uff0c\u4f46\u662f\u7a7a\u95f2\u7684\u5c0f\u5757\u662f\u96f6\u6563\u7684\uff0c\u4e0d\u80fd\u6ee1\u8db3\u7533\u8bf7\u7684\u5927\u5c0f\uff0c\u3002\u8fd9\u53eb\u505a\u201c\u5806\u788e\u7247\u201d\u3002<\/li>\n<li>\u5f53\u65c1\u8fb9\u6709\u7a7a\u95f2\u5757\u7684\u5df2\u7528\u5757\u88ab\u91ca\u653e\u65f6\uff0c\u65b0\u7684\u7a7a\u95f2\u5757\u53ef\u80fd\u4f1a\u4e0e\u76f8\u90bb\u7684\u7a7a\u95f2\u5757\u5408\u5e76\u4e3a\u4e00\u4e2a\u5927\u7684\u7a7a\u95f2\u5757\uff0c\u8fd9\u6837\u53ef\u4ee5\u6709\u6548\u7684\u51cf\u5c11\u201c\u5806\u788e\u7247\u201d\u7684\u4ea7\u751f\u3002<\/li>\n<\/ol>\n<\/ol>\n<h6>\u6808\uff1a<\/h6>\n<ol>\n<ol>\n<li>\u6808\u7ecf\u5e38\u4e0e sp \u5bc4\u5b58\u5668\uff08\u8bd1\u8005\u6ce8\uff1a\u201dstack pointer\u201d\uff0c\u4e86\u89e3\u6c47\u7f16\u7684\u670b\u53cb\u5e94\u8be5\u90fd\u77e5\u9053\uff09\u4e00\u8d77\u5de5\u4f5c\uff0c\u6700\u521d sp \u6307\u5411\u6808\u9876\uff08\u6808\u7684\u9ad8\u5730\u5740\uff09\u3002<\/li>\n<li>CPU \u7528 push \u6307\u4ee4\u6765\u5c06\u6570\u636e\u538b\u6808\uff0c\u7528 pop \u6307\u4ee4\u6765\u5f39\u6808\u3002\u5f53\u7528 push \u538b\u6808\u65f6\uff0csp \u503c\u51cf\u5c11\uff08\u5411\u4f4e\u5730\u5740\u6269\u5c55\uff09\u3002\u5f53\u7528 pop \u5f39\u6808\u65f6\uff0csp \u503c\u589e\u5927\u3002\u5b58\u50a8\u548c\u83b7\u53d6\u6570\u636e\u90fd\u662f CPU \u5bc4\u5b58\u5668\u7684\u503c\u3002<\/li>\n<li>\u5f53\u51fd\u6570\u88ab\u8c03\u7528\u65f6\uff0cCPU\u4f7f\u7528\u7279\u5b9a\u7684\u6307\u4ee4\u628a\u5f53\u524d\u7684 IP \uff08\u8bd1\u8005\u6ce8\uff1a\u201cinstruction pointer\u201d\uff0c\u662f\u4e00\u4e2a\u5bc4\u5b58\u5668\uff0c\u7528\u6765\u8bb0\u5f55 CPU \u6307\u4ee4\u7684\u4f4d\u7f6e\uff09\u538b\u6808\u3002\u5373\u6267\u884c\u4ee3\u7801\u7684\u5730\u5740\u3002CPU \u63a5\u4e0b\u6765\u5c06\u8c03\u7528\u51fd\u6570\u5730\u5740\u8d4b\u7ed9 IP \uff0c\u8fdb\u884c\u8c03\u7528\u3002\u5f53\u51fd\u6570\u8fd4\u56de\u65f6\uff0c\u65e7\u7684 IP \u88ab\u5f39\u6808\uff0cCPU \u7ee7\u7eed\u53bb\u51fd\u6570\u8c03\u7528\u4e4b\u524d\u7684\u4ee3\u7801\u3002<\/li>\n<li>\u5f53\u8fdb\u5165\u51fd\u6570\u65f6\uff0csp \u5411\u4e0b\u6269\u5c55\uff0c\u6269\u5c55\u5230\u786e\u4fdd\u4e3a\u51fd\u6570\u7684\u5c40\u90e8\u53d8\u91cf\u7559\u8db3\u591f\u5927\u5c0f\u7684\u7a7a\u95f4\u3002\u5982\u679c\u51fd\u6570\u4e2d\u6709\u4e00\u4e2a 32-bit \u7684\u5c40\u90e8\u53d8\u91cf\u4f1a\u5728\u6808\u4e2d\u7559\u591f\u56db\u5b57\u8282\u7684\u7a7a\u95f4\u3002\u5f53\u51fd\u6570\u8fd4\u56de\u65f6\uff0csp \u901a\u8fc7\u8fd4\u56de\u539f\u6765\u7684\u4f4d\u7f6e\u6765\u91ca\u653e\u7a7a\u95f4\u3002<\/li>\n<li>\u5982\u679c\u51fd\u6570\u6709\u53c2\u6570\u7684\u8bdd\uff0c\u5728\u51fd\u6570\u8c03\u7528\u4e4b\u524d\uff0c\u4f1a\u5c06\u53c2\u6570\u538b\u6808\u3002\u51fd\u6570\u4e2d\u7684\u4ee3\u7801\u901a\u8fc7 sp \u7684\u5f53\u524d\u4f4d\u7f6e\u6765\u5b9a\u4f4d\u53c2\u6570\u5e76\u8bbf\u95ee\u5b83\u4eec\u3002<\/li>\n<li>\u51fd\u6570\u5d4c\u5957\u8c03\u7528\u548c\u4f7f\u7528\u9b54\u6cd5\u4e00\u6837\uff0c\u6bcf\u4e00\u6b21\u65b0\u8c03\u7528\u7684\u51fd\u6570\u90fd\u4f1a\u5206\u914d\u51fd\u6570\u53c2\u6570\uff0c\u8fd4\u56de\u503c\u5730\u5740\u3001\u5c40\u90e8\u53d8\u91cf\u7a7a\u95f4\u3001\u5d4c\u5957\u8c03\u7528\u7684\u6d3b\u52a8\u8bb0\u5f55\u90fd\u8981\u88ab\u538b\u5165\u6808\u4e2d\u3002\u51fd\u6570\u8fd4\u56de\u65f6\uff0c\u6309\u7167\u6b63\u786e\u65b9\u5f0f\u7684\u64a4\u9500\u3002<\/li>\n<li>\u6808\u8981\u53d7\u5230\u5185\u5b58\u5757\u7684\u9650\u5236\uff0c\u4e0d\u65ad\u7684\u51fd\u6570\u5d4c\u5957\/\u4e3a\u5c40\u90e8\u53d8\u91cf\u5206\u914d\u592a\u591a\u7684\u7a7a\u95f4\uff0c\u53ef\u80fd\u4f1a\u5bfc\u81f4\u6808\u6ea2\u51fa\u3002\u5f53\u6808\u4e2d\u7684\u5185\u5b58\u533a\u57df\u90fd\u5df2\u7ecf\u88ab\u4f7f\u7528\u5b8c\u4e4b\u540e\u7ee7\u7eed\u5411\u4e0b\u5199\uff08\u4f4e\u5730\u5740\uff09\uff0c\u4f1a\u89e6\u53d1\u4e00\u4e2a CPU \u5f02\u5e38\u3002\u8fd9\u4e2a\u5f02\u5e38\u63a5\u4e0b\u4f1a\u901a\u8fc7\u8bed\u8a00\u7684\u8fd0\u884c\u65f6\u8f6c\u6210\u5404\u79cd\u7c7b\u578b\u7684\u6808\u6ea2\u51fa\u5f02\u5e38\u3002\uff08\u8bd1\u8005\u6ce8\uff1a\u201c\u4e0d\u540c\u8bed\u8a00\u7684\u5f02\u5e38\u63d0\u793a\u4e0d\u540c\uff0c\u56e0\u6b64\u901a\u8fc7\u8bed\u8a00\u8fd0\u884c\u65f6\u6765\u8f6c\u6362\u201d\u6211\u60f3\u4ed6\u8868\u8fbe\u7684\u662f\u8fd9\u4e2a\u542b\u4e49\uff09<\/li>\n<\/ol>\n<\/ol>\n<h6>*\u51fd\u6570\u7684\u5206\u914d\u53ef\u4ee5\u7528\u5806\u6765\u4ee3\u66ff\u6808\u5417\uff1f<\/h6>\n<p>\u4e0d\u53ef\u4ee5\u7684\uff0c\u51fd\u6570\u7684\u6d3b\u52a8\u8bb0\u5f55\uff08\u5373\u5c40\u90e8\u6216\u8005\u81ea\u52a8\u53d8\u91cf\uff09\u88ab\u5206\u914d\u5728\u6808\u4e0a\uff0c \u8fd9\u6837\u505a\u4e0d\u4f46\u5b58\u50a8\u4e86\u8fd9\u4e9b\u53d8\u91cf\uff0c\u800c\u4e14\u53ef\u4ee5\u7528\u6765\u5d4c\u5957\u51fd\u6570\u7684\u8ffd\u8e2a\u3002<br \/>\n\u5806\u7684\u7ba1\u7406\u4f9d\u8d56\u4e8e\u8fd0\u884c\u65f6\u73af\u5883\uff0cC \u4f7f\u7528 malloc \uff0cC++ \u4f7f\u7528 new \uff0c\u4f46\u662f\u5f88\u591a\u8bed\u8a00\u6709\u5783\u573e\u56de\u6536\u673a\u5236\u3002<br \/>\n\u6808\u662f\u66f4\u4f4e\u5c42\u6b21\u7684\u7279\u6027\u4e0e\u5904\u7406\u5668\u67b6\u6784\u7d27\u5bc6\u7684\u7ed3\u5408\u5230\u4e00\u8d77\u3002\u5f53\u5806\u4e0d\u591f\u65f6\u53ef\u4ee5\u6269\u5c55\u7a7a\u95f4\uff0c\u8fd9\u4e0d\u96be\u505a\u5230\uff0c\u56e0\u4e3a\u53ef\u4ee5\u6709\u5e93\u51fd\u6570\u53ef\u4ee5\u8c03\u7528\u3002\u4f46\u662f\uff0c\u6269\u5c55\u6808\u901a\u5e38\u6765\u8bf4\u662f\u4e0d\u53ef\u80fd\u7684\uff0c\u56e0\u4e3a\u5728\u6808\u6ea2\u51fa\u7684\u65f6\u5019\uff0c\u6267\u884c\u7ebf\u7a0b\u5c31\u88ab\u64cd\u4f5c\u7cfb\u7edf\u5173\u95ed\u4e86\uff0c\u8fd9\u5df2\u7ecf\u592a\u665a\u4e86\u3002<\/p>\n<h5>\u8bd1\u8005\u6ce8<\/h5>\n<p>\u5173\u4e8e\u5806\u6808\u7684\u8fd9\u4e2a\u5e16\u5b50\uff0c\u5bf9\u6211\u6765\u8bf4\uff0c\u6536\u83b7\u975e\u5e38\u591a\u3002\u6211\u4e4b\u524d\u770b\u8fc7\u4e00\u4e9b\u8d44\u6599\uff0c\u81ea\u5df1\u5199\u4ee3\u7801\u7684\u65f6\u5019\u4e5f\u5e38\u5e38\u601d\u8003\u3002\u5c31\u8fd9\u65b9\u9762\uff0c\u4e5f\u548c\u7965\u5b50\uff08\u6211\u7684\u5927\u5b66\u820d\u53cb\uff0c\u73b0\u5728\u5317\u4eac\u90ae\u7535\u8bfb\u7814\uff0c\u6280\u672f\u725b\u4eba\uff09\u63a2\u8ba8\u8fc7\u591a\u6b21\u4e86\u3002\u4f46\u662f\u7ec8\u7a76\u662f\u4e00\u4e2a\u4e00\u4e2a\u7684\u77e5\u8bc6\u70b9\uff0c\u8fd9\u4e2a\u5e16\u5b50\u770b\u5b8c\u4e4b\u540e\uff0c\u8c41\u7136\u5f00\u6717\uff0c\u628a\u77e5\u8bc6\u70b9\u7ec8\u4e8e\u8fde\u63a5\u6210\u4e86\u4e00\u4e2a\u7f51\u3002\u8fd9\u79cd\u611f\u89c9\uff0c\u7ecf\u5386\u8fc7\u7684\u4e00\u5b9a\u61c2\u5f97\uff0c\u671f\u95f4\u7684\u5174\u594b\u4e0d\u8a00\u800c\u55bb\u3002<\/p>\n<p>\u8fd9\u4e2a\u5e16\u5b50\u8ddf\u5e16\u8005\u4e0d\u5c11\uff0c\u6211\u9009\u4e86\u8bc4\u5206\u6700\u9ad8\u7684\u56db\u4e2a\u3002\u8fd9\u56db\u4e2a\u4e4b\u95f4\u4e5f\u6709\u4e00\u4e9b\u662f\u91cd\u590d\u7684\u89c2\u70b9\u3002\u4e2a\u4eba\u949f\u7231\u7b2c\u56db\u4e2a\u56de\u7b54\u8005\uff0c\u6211\u770b\u7684\u65f6\u5019\uff0c\u77ac\u95f4\u9ad8\u6f6e\u4e86\uff0c\u6709\u6728\u6709\uff1f\u4e0d\u8fc7\u9700\u8981\u4e00\u4e9b\u6c47\u7f16\u8bed\u8a00\u3001\u64cd\u4f5c\u7cfb\u7edf\u3001\u8ba1\u7b97\u673a\u7ec4\u6210\u539f\u7406\u7684\u7684\u57fa\u7840\uff0c\u77e5\u9053\u90a3\u51e0\u4e2a\u5bc4\u5b58\u5668\u662f\u5e72\u4ec0\u4e48\u7684\uff0c\u8981\u77e5\u9053\u8ba1\u7b97\u673a\u7684\u6d41\u6c34\u7ebf\u6307\u4ee4\u5de5\u4f5c\u673a\u5236\uff0c\u4fdd\u62a4\/\u6062\u590d\u73b0\u573a\u7b49\u6982\u5ff5\u3002\u4e09\u4e2a\u56de\u590d\u8005\u90fd\u6d89\u53ca\u5230\u4e86\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u865a\u62df\u5185\u5b58\uff1b\u5728\u6bd4\u8f83\u901f\u5ea6\u7684\u65f6\u5019\uff0c\u5927\u5bb6\u4e00\u5b9a\u8981\u5728\u8111\u4e2d\u5bf9\u201c\u5c40\u90e8\u6027\u539f\u7406\u201d\u548c\u8ba1\u7b97\u673a\u9ad8\u901f\u7f13\u5b58\u6709\u4e00\u4e2a\u6982\u5ff5\u3002<\/p>\n<p>\u5982\u679c\u4f60\u628a\u8fd9\u7bc7\u6587\u7ae0\u770b\u61c2\u4e86\uff0c\u6211\u76f8\u4fe1\u4f60\u6536\u83b7\u7684\u4e0d\u53ea\u662f\u5806\u548c\u6808\uff0c\u4f60\u4f1a\u7406\u89e3\u7684\u66f4\u591a\uff01<\/p>\n<p>\u5174\u594b\u4e4b\u4f59\uff0c\u6709\u51e0\u70b9\u8fd8\u662f\u8981\u5f3a\u8c03\u7684\uff0c\u7ffb\u8bd1\u6ca1\u6709\u9010\u5b57\u9010\u8bcd\u7ffb\u8bd1\uff0c\u5927\u90e8\u5206\u662f\u901a\u8fc7\u6211\u4e2a\u4eba\u7684\u77e5\u8bc6\u79ef\u7d2f\u548c\u5bf9\u56de\u5e16\u8005\u7684\u610f\u56fe\u63e3\u6d4b\u800c\u6765\u7684\u3002\u8bf7\u5927\u5bb6\u4e0d\u8981\u54ac\u6587\u56bc\u5b57\uff0c\u9010\u4e2a\u63a8\u6572\uff0c\u6211\u4eec\u7684\u76ee\u7684\u5728\u4e8e\u6280\u672f\u4ea4\u6d41\uff0c\u4e0d\u662f\u4e48\uff1f\u8fbe\u5230\u8fd9\u4e00\u76ee\u7684\u5c31\u591f\u4e86\u3002<\/p>\n<h6>\u4e0b\u9762\u662f\u4e00\u4e9b\u4e0d\u786e\u5b9a\u70b9\uff1a<\/h6>\n<p>\u6211\u6ca1\u6709\u542c\u8fc7 bookkeeping data \u8fd9\u79cd\u8bf4\u6cd5\uff0c\u6545\u6ca1\u6709\u7ffb\u8bd1\u3002\u4ece\u4e0a\u4e0b\u6587\u7406\u89e3\u6765\u770b\uff0c\u53ef\u4ee5\u60f3\u6210\u662f\u7528\u6765\u5bc4\u5b58\u5668\u503c\uff1f\u51fd\u6570\u53c2\u6570\uff1f\u8fd4\u56de\u5730\u5740\uff1f\u5982\u679c\u6709\u4e86\u89e3\u5177\u4f53\u542b\u4e49\u7684\u670b\u53cb\uff0c\u70e6\u8bf7\u544a\u77e5\u3002<\/p>\n<p>\u6808\u548c\u5806\u6808\u662f\u4e00\u56de\u4e8b\uff0c\u82f1\u6587\u8868\u8fbe\u662f stack\uff0c\u5806\u662f heap\u3002<\/p>\n<p>\u8c03\u7528\u6808\u7684\u6982\u5ff5\uff0c\u6211\u662f\u7b2c\u4e00\u6b21\u542c\u8bf4\uff0c\u4e0d\u592a\u719f\u6089\u3002\u5927\u5bb6\u53ef\u4ee5\u53bb\u67e5\u67e5\u8d44\u6599\u7814\u7a76\u4e00\u4e0b\u3002<\/p>\n<p>\u4ee5\u4e0a\uff0c\u9001\u7ed9\u5927\u5bb6\uff0c\u672c\u6587\u7ed3\u675f\u3002<\/p>\n<p>\u539f\u6587\u5730\u5740\uff1a<a href=\"http:\/\/blog.jobbole.com\/75321\/\" target=\"_blank\">\u4ec0\u4e48\u662f\u5806\u548c\u6808\uff0c\u5b83\u4eec\u5728\u54ea\u513f\uff1f &#8211; \u535a\u5ba2 &#8211; \u4f2f\u4e50\u5728\u7ebf<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u8fdc\u79bb\u4e66\u672c\/\u8bfe\u5802\u592a\u4e45\uff0c\u5bf9\u8ba1\u7b97\u673a\u4e2d\u7684\u4e00\u4e9b\u57fa\u672c\u77e5\u8bc6\u90fd\u4e0d\u719f\u6089\u4e86\uff0c\u524d\u4e9b\u5929\u4e00\u76f4\u90fd\u5728\u60f3\u522b\u7684\u4e8b\u60c5\uff0c\u6ca1\u6709\u65f6\u95f4\uff08\u5176\u5b9e\u4eca\u5929\u4e5f\u6ca1\u4ec0\u4e48\u65f6 [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[313,314],"class_list":["post-995","post","type-post","status-publish","format-standard","hentry","category-knowledgebase-2","tag-heap","tag-stack"],"views":5042,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/995","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=995"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/995\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}