{"id":3018,"date":"2016-01-19T15:44:08","date_gmt":"2016-01-19T07:44:08","guid":{"rendered":"https:\/\/www.ecjtu.com\/keith\/archives\/3018"},"modified":"2016-01-19T15:44:08","modified_gmt":"2016-01-19T07:44:08","slug":"%e4%bb%80%e4%b9%88%e6%98%af%e5%a0%86%e5%92%8c%e6%a0%88%ef%bc%8c%e5%ae%83%e4%bb%ac%e5%9c%a8%e5%93%aa%e5%84%bf%ef%bc%9f","status":"publish","type":"post","link":"https:\/\/www.ecjtu.com\/keith\/archives\/3018","title":{"rendered":"\u4ec0\u4e48\u662f\u5806\u548c\u6808\uff0c\u5b83\u4eec\u5728\u54ea\u513f\uff1f"},"content":{"rendered":"<h3>\u95ee\u9898\uff1aWhat and where are the stack and heap?<\/h3>\n<h3>\u95ee\u9898\u63cf\u8ff0<\/h3>\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<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<h3>\u7b54\u6848\u4e00<\/h3>\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<h3>\u7b54\u6848\u4e8c<\/h3>\n<p><strong>Stack:<\/strong><\/p>\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<p><strong>Heap\uff1a<\/strong><\/p>\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<p>\u4e3e\u4f8b\uff1a<\/p>\n<pre class=\"lang:c++ decode:true \">int foo()\r\n{\r\n  char *pBuffer; \/\/&lt;--nothing allocated yet (excluding the pointer itself, which is allocated here on the stack).\r\n  bool b = true; \/\/ Allocated on the stack.\r\n  if(b)\r\n  {\r\n    \/\/Create 500 bytes on the stack\r\n    char buffer[500];\r\n\r\n    \/\/Create 500 bytes on the heap\r\n    pBuffer = new char[500];\r\n\r\n   }\/\/&lt;-- buffer is deallocated here, pBuffer is not\r\n}\/\/&lt;--- oops there's a memory leak, I should have called delete[] pBuffer;<\/pre>\n<h3>\u7b54\u6848\u4e09<\/h3>\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=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/8fb5e10cc2c0a32a009ee5a81ae5e7fe.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-medium size-medium\" src=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/8fb5e10cc2c0a32a009ee5a81ae5e7fe.jpg\" alt=\"8fb5e10cc2c0a32a009ee5a81ae5e7fe\" width=\"255\" height=\"282\" \/><\/a><\/p>\n<p>&nbsp;<\/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=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/a3992ba4954f116ac93e51c8748e33ad.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-medium size-medium\" src=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/a3992ba4954f116ac93e51c8748e33ad.jpg\" alt=\"a3992ba4954f116ac93e51c8748e33ad\" width=\"160\" height=\"120\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>\u4e0a\u9762\u4e0a\u4e2a\u56fe\u7247\u5f88\u597d\u7684\u63cf\u8ff0\u4e86\u5806\u548c\u6808\u5206\u914d\u5185\u5b58\u7684\u65b9\u5f0f\u3002<\/p>\n<p><strong>\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<\/strong><\/p>\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<a href=\"http:\/\/en.wikipedia.org\/wiki\/Call_stack\">\u8c03\u7528\u6808<\/a>\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<p><strong>\u5b83\u4eec\u7684\u4f5c\u7528\u8303\u56f4\u662f\u4ec0\u4e48\uff1f<\/strong><\/p>\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<p><strong>\u5b83\u4eec\u7684\u5927\u5c0f\u7531\u4ec0\u4e48\u51b3\u5b9a\uff1f<\/strong><\/p>\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<p><strong>\u54ea\u4e2a\u66f4\u5feb\u4e00\u4e9b\uff1f<\/strong><\/p>\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<h3>\u7b54\u6848\u56db<\/h3>\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<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<p><strong>\u5806:<\/strong><\/p>\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<p><a href=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/b4f167893c867d7380c47add6ccf887a.png\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-medium size-medium\" src=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/b4f167893c867d7380c47add6ccf887a.png\" alt=\"b4f167893c867d7380c47add6ccf887a\" width=\"571\" height=\"392\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><strong>\u6808:<\/strong><\/p>\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<p><a href=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/4cc14ac67f20aa09657ceb6e1bff1ff7.png\"><img loading=\"lazy\" decoding=\"async\" class=\"attachment-medium size-medium\" src=\"https:\/\/www.ecjtu.com\/keith\/wp-content\/uploads\/2016\/01\/4cc14ac67f20aa09657ceb6e1bff1ff7.png\" alt=\"4cc14ac67f20aa09657ceb6e1bff1ff7\" width=\"594\" height=\"513\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p><em>*\u51fd\u6570\u7684\u5206\u914d\u53ef\u4ee5\u7528\u5806\u6765\u4ee3\u66ff\u6808\u5417\uff1f<\/em><\/p>\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<\/p>\n<p>\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<\/p>\n<p>\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<h2>\u8bd1\u8005\u6ce8<\/h2>\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<p>\u4e0b\u9762\u662f\u4e00\u4e9b\u4e0d\u786e\u5b9a\u70b9:<\/p>\n<ol>\n<li>\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<\/li>\n<li>\u6808\u548c\u5806\u6808\u662f\u4e00\u56de\u4e8b\uff0c\u82f1\u6587\u8868\u8fbe\u662f stack\uff0c\u5806\u662f heap\u3002<\/li>\n<li>\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<\/li>\n<\/ol>\n<p>\u4ee5\u4e0a\uff0c\u9001\u7ed9\u5927\u5bb6\uff0c\u672c\u6587\u7ed3\u675f\u3002<\/p>\n<p>\u6765\u81ea\uff1a \u72ec\u914c\u9038\u9189<br \/>\n\u94fe\u63a5\uff1ahttp:\/\/www.perfect-is-shit.com\/what-and-where-are-the-stack-and-heap.html<br \/>\n\u539f\u6587\uff1a<a href=\"http:\/\/stackoverflow.com\/questions\/79923\/what-and-where-are-the-stack-and-heap\" target=\"_blank\">http:\/\/stackoverflow.com\/questions\/79923\/what-and-where-are-the-stack-and-heap<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u95ee\u9898\uff1aWhat and where are the stack and heap? \u95ee\u9898\u63cf\u8ff0 \u7f16\u7a0b\u8bed\u8a00\u4e66\u7c4d\u4e2d\u7ecf [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3019,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[66,168],"tags":[930,929,211,928,927],"_links":{"self":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts\/3018"}],"collection":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/comments?post=3018"}],"version-history":[{"count":1,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts\/3018\/revisions"}],"predecessor-version":[{"id":3023,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/posts\/3018\/revisions\/3023"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/media\/3019"}],"wp:attachment":[{"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/media?parent=3018"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/categories?post=3018"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ecjtu.com\/keith\/wp-json\/wp\/v2\/tags?post=3018"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}