{"id":420130,"date":"2021-04-01T09:16:16","date_gmt":"2021-04-01T01:16:16","guid":{"rendered":"http:\/\/4563.org\/?p=420130"},"modified":"2021-04-01T09:16:16","modified_gmt":"2021-04-01T01:16:16","slug":"%e4%bd%bf%e7%94%a8%e5%a0%86%e5%86%85%e5%ad%98%e4%b8%ba%e4%bb%80%e4%b9%88%e6%af%94%e6%a0%88%e5%86%85%e5%ad%98%e6%85%a2%e5%be%88%e5%a4%9a%e5%be%88%e5%a4%9a%ef%bc%9f%e7%94%b3%e8%af%b7%e5%a0%86%e5%86%85","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=420130","title":{"rendered":"\u4f7f\u7528\u5806\u5185\u5b58\u4e3a\u4ec0\u4e48\u6bd4\u6808\u5185\u5b58\u6162\u5f88\u591a\u5f88\u591a\uff1f\u7533\u8bf7\u5806\u5185\u5b58\u9700\u8981\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u5417\uff1f"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u4f7f\u7528\u5806\u5185\u5b58\u4e3a\u4ec0\u4e48\u6bd4\u6808\u5185\u5b58\u6162\u5f88\u591a\u5f88\u591a\uff1f\u7533\u8bf7\u5806\u5185\u5b58\u9700\u8981\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u5417\uff1f               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <span><i><\/i> 0<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u5982\u9898\uff0c\u505a\u4e86\u4e00\u4e2a C \u8bed\u8a00\u5c0f\u5b9e\u9a8c\uff0c\u6211\u5206\u522b\u8fdb\u884c\u4e86\u4e24\u4e2a\u64cd\u4f5c\uff0c<\/p>\n<p>\u5176\u4e00\u662f\u5728\u5806\u4e0a\u7533\u8bf7\u4e00\u4e2a\u957f\u5ea6\u4e3a\u4e00\u4ebf\u7684\u5411\u91cf\uff0c\u7528\u6765\u50a8\u5b58 double \u7c7b\u578b\u7684\u6570\u636e\uff08\u5305\u542b\u521d\u59cb\u5316\uff0c\u5168\u90e8\u4e3a 0 \uff09<\/p>\n<p>\u5176\u4e8c\u662f\u5728\u4e00\u4e2a\u4e00\u4e07\u6b21\u7684\u5faa\u73af\u91cc\u91cd\u590d\u521b\u5efa\u957f\u5ea6\u4e3a\u4e00\u4e07\u7684\u6570\u7ec4\uff0c\u7c7b\u578b\u540c\u6837\u4e3a double\uff0c\u540c\u6837\u521d\u59cb\u5316\u4e3a 0<\/p>\n<p>\u7406\u8bba\u4e0a\u4e24\u8005\u90fd\u6d89\u53ca\u5230 cpu \u5728\u5185\u5b58\u4e0a\u586b\u5165\u4e00\u4ebf\u4e2a 0\uff0c\u4f46\u540e\u8005\u7684\u901f\u5ea6\u6bd4\u524d\u8005\u8981\u5feb 30 \u591a\u500d\u3002\u8fd9\u8ba9\u6211\u60f3\u5230\u4e00\u4e2a\u95ee\u9898\uff0c\u5c31\u662f\u4f20\u7edf\u90fd\u8ba4\u4e3a\u5806\u6bd4\u8f83\u6162\uff0c\u800c\u6162\u4ea7\u751f\u7684\u539f\u56e0\u662f\u4ec0\u4e48\uff0c\u5806\u548c\u6808\u90fd\u662f\u666e\u901a\u5185\u5b58\uff0c\u7406\u8bba\u4e0a\u5e94\u5e76\u65e0\u786c\u4ef6\u5c42\u9762\u7684\u533a\u522b\u3002\u96be\u9053\u7a0b\u5e8f\u7533\u8bf7\u5806\u5185\u5b58\u90fd\u5fc5\u987b\u8981\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u624d\u5bfc\u81f4\u901f\u5ea6\u53d8\u6162\u5417\uff1f\u4f46\u662f\u611f\u89c9\u53c8\u8ddf\u4f20\u7edf\u7ecf\u9a8c\u4e0d\u7b26\uff0c\u6bd5\u7adf\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u662f\u4e00\u4e2a\u975e\u5e38\u6602\u8d35\u7684\u64cd\u4f5c\uff0c\u603b\u4e0d\u53ef\u80fd\u7a0b\u5e8f\u5185\u90e8\u6240\u6709\u52a8\u6001\u7279\u6027\u90fd\u8981\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u5427\u3002<\/p>\n<p>\u4e0d\u8fc7\u4e0d\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7684\u8bdd\uff0c\u53c8\u4e3a\u4ec0\u4e48\u4f1a\u6162\u8fd9\u4e48\u591a\u5462\uff1f<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>43<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"5609336\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : BrettD <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u7533\u8bf7\u5806\u5185\u5b58\u8d70 malloc \u554a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609337\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 2435043xia <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5370\u8c61\u4e2d\u662f\u7f13\u5b58\u4f4d\u7f6e\u4e0d\u540c\uff0c\u6808\u662f\u4e00\u7ea7\u7f13\u5b58\uff0c\u5806\u662f\u4e8c\u7ea7\u7f13\u5b58\uff0c\u4e24\u8005\u901f\u5ea6\u5929\u5dee\u5730\u522b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609338\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 12101111 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u770b\u4e00\u4e0b malloc \u90fd\u5e72\u4e86\u4ec0\u4e48 https:\/\/github.com\/microsoft\/mimalloc                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609339\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : lsylsy2 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5176\u4e8c\u662f\u5728\u4e00\u4e2a\u4e00\u4e07\u6b21\u7684\u5faa\u73af\u91cc\u91cd\u590d\u521b\u5efa\u957f\u5ea6\u4e3a\u4e00\u4e07\u7684\u6570\u7ec4\uff0c\u7c7b\u578b\u540c\u6837\u4e3a double\uff0c\u540c\u6837\u521d\u59cb\u5316\u4e3a 0<\/p>\n<p>\u786e\u8ba4\u662f\u4e00\u4e07\u4e2a\u72ec\u7acb\u7684\u6570\u7ec4\u5417\uff1f\u542c\u8d77\u6765\u6709\u53ef\u80fd\u5faa\u73af\u6bcf\u6b21\u7ed3\u675f\uff0c\u6570\u7ec4\u90fd\u88ab\u91ca\u653e\u4e86\uff0c\u6240\u4ee5\u4f60\u5b9e\u9645\u662f\u53cd\u590d\u5199\u4e86\u540c\u4e00\u4e2a\u6570\u7ec4\u4e00\u4e07\u6b21\u3002\u90a3\u4e48\u7f13\u5b58\u7b49\u7b49\u5dee\u8ddd\u5c31\u5f88\u663e\u7136\u4e86\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609340\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Justin13 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u597d\u50cf\u6808\u7684\u5f00\u8f9f\u662f\u65e0\u8111\u7684\uff0c\u4e0d\u7528\u5bfb\u5740\uff0c\u5730\u5740\u76f4\u63a5\u504f\u79fb\u5c31\u597d\uff0c\u800c\u5806\u5fc5\u987b\u626b\u63cf\u627e\u5230\u4e00\u4e2a\u5408\u9002\u7684\u4f4d\u7f6e\u3002\u8fd9\u5c31\u8d39\u65f6\u95f4\u4e86                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609341\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dalabenba <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e0d\u662f\u56e0\u4e3a\u5806\u548c\u6808\u7684\u95ee\u9898\uff0c\u4ed6\u4eec\u901f\u5ea6\u662f\u4e00\u6837\u7684\u3002\u662f\u56e0\u4e3a cache,\u548c pagefault,\u7b2c\u4e00\u4e2a\u7a0b\u5e8f\u6bcf\u4e2a\u90fd\u662f\u7b2c\u4e00\u6b21\u8bbf\u95ee\uff0c\u6bcf\u4e2a\u9875\u9762\u90fd\u4f1a\u89e6\u53d1 pagefault\uff0c\u4ee5\u53ca cache miss \u4f1a\u6bd4\u8bbf\u95ee\u540c\u4e00\u6bb5\u5730\u5740\u9ad8\uff0c\u7b2c\u4e8c\u56e0\u4e3a\u5728\u6808\u4e0a\u6ca1\u6709 pagefault \u7684\u95ee\u9898\uff0c\u800c\u4e14\u653e\u5728\u6808\u4e0a\u7684\u8bdd\u6bcf\u6b21\u5faa\u73af\u7684\u5730\u5740\u76f8\u540c\uff0ccache hit \u7387\u9ad8                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609342\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @lsylsy2 \u663e\u7136\u662f\u88ab\u91ca\u653e\u4e86\uff0c\u6808\u7a7a\u95f4\u6709\u9650\u600e\u4e48\u53ef\u80fd\u8ba9\u4f60\u65e0\u9650\u5199\u4e0b\u53bb\u3002\u4e0d\u8fc7\u8fd9\u4e2a\u7eaf\u5199\u5165\u64cd\u4f5c\uff0c\u7f13\u5b58\u5f71\u54cd\u4e0d\u5927\u5427                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609343\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dalabenba <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dalabenba \u8bf4\u53c9\u4e86\uff0c\u6808\u4e0a\u5185\u5b58\u4e0d\u4f1a pagefault \u539f\u56e0\u662f\u5b9e\u9645\u8bbf\u95ee\u7684\u90fd\u662f\u540c\u4e00\u6bb5\uff0c\u6700\u591a\u53ea\u8981 pagefault \u4e00\u6b21\u5c31\u597d                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609344\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @Justin13 \u5806\u5185\u5b58\u903b\u8f91\u4e0a\u662f\u8fde\u7eed\u7684\uff0c\u5e94\u8be5\u53ea\u7528\u626b\u63cf\u4e00\u6b21\uff0c\u611f\u89c9\u4e0d\u662f\u5f71\u54cd\u7684\u4e3b\u8981\u539f\u56e0                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609345\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @12101111 \u770b\u4e0d\u61c2\u554a\u5927\u4f6c                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609346\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dalabenba \u5927\u4f6c\uff0c\u4ed6\u8fd9\u4e2a malloc \u9700\u8981\u7ecf\u8fc7\u7cfb\u7edf\u5417\uff1f\u5b66 io \u7684\u65f6\u5019\u90fd\u8bf4\u6700\u597d\u4e0d\u8981\u7ecf\u8fc7\u7cfb\u7edf\uff0c\u5f00\u9500\u5927\u3002\u8fd9\u4e2a malloc \u5982\u679c\u9700\u8981\u7ecf\u8fc7\u7cfb\u7edf\u7684\u8bdd\uff0c\u90a3\u4e48\u7cfb\u7edf\u5fc5\u7136\u4e5f\u8981\u7ecf\u8fc7\u7528\u6237\u6001\u5207\u6362\u5185\u6838\u6001\uff0c\u4ece ring3 \u5207\u6362\u5230 ring0 \u624d\u80fd\u64cd\u4f5c\u5806\u5185\u5b58\u5427\u3002\u5982\u679c\u662f\u8fd9\u6837\u7684\u8bdd\u611f\u89c9\u5e94\u7528\u7a0b\u5e8f\u4e0d\u5e94\u8be5\u8fd9\u4e48\u5feb\u554a\uff0c\u6bd4\u5982 java \u5f53\u4e2d\u4e5f\u6709\u5927\u91cf\u7684\u52a8\u6001\u7279\u6027\uff0c\u5982\u679c\u5168\u90fd\u9700\u8981\u7ecf\u8fc7\u64cd\u4f5c\u7cfb\u7edf\u7684\u8bdd\u5f00\u9500\u4e0d\u662f\u975e\u5e38\u5927\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609347\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ho121 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9996\u5148\u9700\u8981\u4e86\u89e3\u8fdb\u7a0b\u7684\u5185\u5b58\u7ed3\u6784 https:\/\/www.geeksforgeeks.org\/memory-layout-of-c-program\/<\/p>\n<p>\u7136\u540e\u4e86\u89e3\u4e00\u4e0b\u5728\u6808\u4e2d\u7533\u8bf7\u5185\u5b58\u7684\u8fc7\u7a0b https:\/\/stackoverflow.com\/a\/8629324\/1968839<\/p>\n<p>\u7136\u540e\u4e86\u89e3\u4e00\u4e0b malloc \u662f\u600e\u4e48\u5de5\u4f5c\u7684<br \/>https:\/\/stackoverflow.com\/a\/3479496\/1968839                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609348\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Whurry <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u9996\u5148\u662f\u6808\u7a7a\u95f4\u80fd\u8fd9\u4e48\u5927\u5417\uff1f\u6808\u91cc\u5e94\u8be5\u5b58\u4e0d\u4e0b\u8fd9\u4e9b\u6570\u636e\u3002<\/p>\n<p>\u7b2c\u4e8c\u70b9\u662f\u8fdb\u7a0b\u5411\u64cd\u4f5c\u7a7a\u95f4\u7533\u8bf7\u5185\u5b58\u7a7a\u95f4\u65f6\uff0c\u4e00\u822c\u662f\u5148\u865a\u62df\u5185\u5b58\u7ed9\u5b89\u6392\u4e0a\uff0c\u8bbf\u95ee\u7684\u65f6\u5019\u53d1\u73b0\u6ca1\u6709\u5bf9\u5e94\u7684\u7269\u7406\u5730\u5740\uff0c\u89e6\u53d1 pagefault\uff0c\u7136\u540e\u624d\u7ed9\u865a\u62df\u5730\u5740\u5b89\u6392\u4e0a\u5bf9\u5e94\u7684\u7269\u7406\u5730\u5740\u3002\u4e00\u4e2a\u9875\u4e00\u822c\u662f 4KB \u3002<\/p>\n<p>\u4e0d\u786e\u5b9a\u5bf9\u4e0d\u5bf9\uff0c\u4ec5\u4f9b\u53c2\u8003                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609349\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @ho121 \u611f\u8c22\uff0c\u770b\u5b8c\u4e86\u3002\u53e6\u5916\u6211\u89c9\u5f97\u8fd9\u4e9b\u56de\u7b54\u5199\u7684\u4e0d\u5bf9\uff0c\u6211\u53c8\u505a\u4e86\u4e2a\u5c0f\u5b9e\u9a8c\uff0c\u5728\u4e00\u767e\u4e07\u6b21 for \u5faa\u73af\u91cc\uff0c\u6bcf\u6b21\u5faa\u73af\u65b0\u5efa\u4e00\u5757\u88ab malloc \u7684\u5185\u5b58\uff08\u8be5\u5185\u5b58\u957f\u5ea6\u4e3a 2 \u4e2a double\uff0c\u6240\u4ee5\u4e0d\u4f1a\u4ea7\u751f\u8fc7\u5927\u7684\u95ee\u9898\uff09\uff0c\u7edf\u8ba1\u6267\u884c\u65f6\u95f4\u4e00\u767e\u4e07\u6b21\u4ec5\u4e3a 200ns\uff0c\u5982\u679c\u6309\u7167\u6587\u7ae0\u4e2d\u8bf4 malloc \u90fd\u9700\u8981\u7ecf\u8fc7\u7cfb\u7edf\u8c03\u7528\u7684\u8bdd\uff0c\u4f20\u7edf\u4e00\u822c\u8ba4\u4e3a\u7cfb\u7edf\u8c03\u7528\u6700\u77ed\u4e5f\u662f\u767e\u7eb3\u79d2\u8fd9\u4e2a\u6570\u91cf\u7ea7\u7684\uff0c\u600e\u4e48\u53ef\u80fd\u8fd9\u4e48\u5feb\u5462\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609350\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : misaka19000 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5728\u6808\u4e0a\u9762\u53ea\u9700\u8981\u79fb\u52a8\u6808\u6307\u9488\u5c31\u53ef\u4ee5<\/p>\n<p>\u5728\u5806\u4e0a\u9762\u6709\u4e00\u5927\u5806\u4e71\u4e03\u516b\u7cdf\u7684\u64cd\u4f5c\uff0c\u800c\u4e14\u7533\u8bf7\u5806\u8981\u8d70\u7cfb\u7edf\u8c03\u7528\u7684                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609351\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : love <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ee3\u7801\u4e0d\u653e\u51fa\u6765\u770b\u770b\uff1f<\/p>\n<p>\u5206\u914d\u673a\u5236\u4e0d\u4e00\u6837\uff0c\u6808\u4e0a\u80af\u5b9a\u4e0d\u80fd\u7533\u8bf7\u8fd9\u4e48\u5927\u7684\u5185\u5b58\u91cf\uff0c\u6808\u5927\u5c0f\u5f88\u5c0f\u7684\uff0c\u5426\u5219\u4f60\u603b\u542c\u8bf4\u8fc7 stack overflow \u8fd9\u4e2a\u8bcd                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609352\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ho121 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @LeeReamond \u7a0b\u5e8f\u4e2d malloc \u4e00\u6b21\u4e00\u4e2a\u5c0f\u7684\u5185\u5b58\uff0c\u6bd4\u5982 8 \u5b57\u8282\uff0c\u5b9e\u9645 malloc \u5728\u80cc\u540e\u4e0d\u4f1a\u8001\u8001\u5b9e\u5b9e\u7684\u771f\u7684\u5411\u7cfb\u7edf\u53ea\u7533\u8bf7 8 \u5b57\u8282\uff0c\u5927\u90e8\u5206\u60c5\u51b5\u4e0b\u4f1a\u4e00\u6b21\u7533\u8bf7\u8f83\u5927\u7684\u5185\u5b58\uff0c\u4ee5\u4f9b\u540e\u9762\u4f7f\u7528\u3002malloc \u53ea\u6709\u5411\u7cfb\u7edf\u7533\u8bf7\u5185\u5b58\u65f6\uff0c\u624d\u4f1a\u7528\u5230\u7cfb\u7edf\u8c03\u7528                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609353\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dalabenba <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @LeeReamond malloc \u662f libc \u5b9e\u73b0\u7684\u4e0d\u662f\u7cfb\u7edf\u8c03\u7528\uff0c\u5e95\u5c42\u7cfb\u7edf\u8c03\u7528\u7684\u63a5\u53e3\u662f mmap \u6216\u8005 brk \u3002\u4e00\u822c malloc \u4f1a\u9884\u5148\u5206\u914d\u4e00\u7684\u5185\u5b58\u5757\uff0c\u7136\u540e\u628a\u5185\u5b58\u5757\u5206\u5272\uff0c\u52a0\u5165\u5230\u81ea\u5df1\u7684\u5185\u5b58\u6c60\u4e2d\u3002\u5f53 malloc \u81ea\u5df1\u7684\u5185\u5b58\u6c60\u4e2d\u6ca1\u6709\u8db3\u591f\u7684\u5185\u5b58\u65f6\u5019\uff0c\u624d\u7528\u7cfb\u7edf\u8c03\u7528\u4f1a\u4ece\u7cfb\u7edf\u4e2d\u62ff\u3002pagefault \u4f1a\u53d1\u751f\u5728\u7cfb\u7edf\u8c03\u7528\u540e\u62ff\u5230\u5185\u5b58\u540e\uff0c\u7b2c\u4e00\u6b21\u5199\u6216\u8005\u8bfb\u3002\u6240\u4ee5\u521a\u521a\u8bf4\u5f97\u8fd8\u4e0d\u591f\u4e25\u8c28\uff0c\u8981\u662f\u5185\u5b58\u662f\u4ece\u5185\u5b58\u6c60\u4e2d\u62ff\uff0c\u4e14\u5df2\u7ecf\u8bbf\u95ee\u8fc7\u4e86\uff0c\u800c\u4e0d\u662f\u7cfb\u7edf\u8c03\u7528\u65b0\u5206\u914d\u7684\u8bdd\uff0c\u662f\u4e0d\u4f1a\u53d1\u751f pagefault \u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609354\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : ho121 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @LeeReamond \u6bd4\u5982\u8fd9\u91cc\u6709\u4ecb\u7ecd https:\/\/medium.com\/@andrestc\/implementing-malloc-and-free-ba7e7704a473 sbrk \u662f Linux \u4e2d\u7684\uff0cWindows \u7cfb\u7edf\u4e2d\u5e94\u8be5\u4e5f\u6709\u5bf9\u5e94\u7684 api                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609355\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @love \u8bf7\u53c2\u8003\u56db\u548c\u4e03\uff0c\u73b0\u5728\u662f\u624b\u673a\u64cd\u4f5c\u6682\u65f6\u6ca1\u6cd5\u653e\u4ee3\u7801\uff0c\u4e0d\u8fc7\u672c\u8eab\u903b\u8f91\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u53d1\u5e16\u65f6\u89c9\u5f97\u6ca1\u6709\u5fc5\u8981\u653e                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609356\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : godblessumilk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u571f\u5b57\u65c1\u7684 [\u5806] \u662f\u4e00\u76d8\u6563\u6c99\u3002\u6728\u5b57\u65c1\u7684 [\u6808] \u662f\u7801\u653e\u5f97\u6574\u6574\u9f50\u9f50\u7684\u6728\u677f\uff0c\u4e00\u6367\u6c99\u91cc\u627e\u4e00\u9897\u6c99\u5b50\u5feb\uff0c\u8fd8\u662f\u4e00\u645e\u6728\u677f\u91cc\u627e\u4e00\u5757\u6728\u677f\u5feb\uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609357\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : godblessumilk <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u4ee5\u67e5\u67e5\u82f1\u6587\u5355\u8bcd stack \u548c heap \u7684\u533a\u522b\uff0c\u5c31\u660e\u767d\u4e86\u3002\u8bdd\u8bf4\u4e2d\u6587\u91cc stack \u7ffb\u8bd1\u6210\u5806\uff0cheap \u7ffb\u8bd1\u6210\u6808\uff0c\u8fd8\u633a\u8d34\u5207\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609358\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : LeeReamond <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @godblessumilk \u5144\u5f1f\u4f60\u8fd9\u4e2a\u5806\u6808\u81ea\u5df1\u90fd\u80fd\u5199\u9519\u5c31\u522b\u6765\u5f3a\u7b54\u4e86\u5427\u3002\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609359\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 3dwelcome <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @LeeReamond &#8220;\u4e0d\u8fc7\u672c\u8eab\u903b\u8f91\u6bd4\u8f83\u7b80\u5355\uff0c\u6211\u53d1\u5e16\u65f6\u89c9\u5f97\u6ca1\u6709\u5fc5\u8981\u653e&#8221;<br \/>\u7f16\u8bd1\u5668\u4f1a\u4f18\u5316\u6389\u5f88\u591a\uff0c\u4f60\u5199\u51fa\u6765\u7684\u4ee3\u7801\uff0c\u4e0d\u4e00\u5b9a\u662f\u6700\u540e\u8fd0\u884c\u7684\u4ee3\u7801\u3002\u6bd4\u5982\u53ea new \u4e0d\u586b\u5145\uff0c\u7cfb\u7edf\u662f\u4e0d\u4f1a\u7ed9\u4f60\u771f\u6b63\u5206\u914d\u5185\u5b58\u7684\u3002<\/p>\n<p>\u4e2a\u4eba\u7ecf\u9a8c\uff0c\u5f71\u54cd\u5185\u5b58\u901f\u5ea6\u6709\u4e09\u70b9\u3002<br \/>1 \u3002 \u5bfb\u5740\u7a7a\u95f4\u5927\u5c0f\uff0c\u6211\u6709\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u76f8\u540c\u7684\u4ee3\u7801\uff0c\u8bbf\u95ee 256M \u4e4b\u5185\u65f6\u8d85\u5feb\uff0c\u8bbf\u95ee 4G \u7a7a\u95f4\u65f6\uff0c\u901f\u5ea6\u4e0b\u964d\u4e00\u534a\u3002<br \/>2 \u3002\u5185\u5b58\u5bf9\u9f50\uff0cx86 \u8bbf\u95ee\u975e\u5bf9\u9f50\u5185\u5b58\uff0c\u4f1a\u6709\u989d\u5916\u591a\u4f59\u5f00\u9500\u3002<br \/>3 \u3002\u5c31\u662f malloc(\u5806)\u548c alloca(\u6808)\u533a\u522b\u4e86\uff0c\u540e\u8005\u662f\u771f\u7684\u5feb\uff0c\u7528\u98de\u901f\u4e5f\u4e0d\u4e3a\u8fc7\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609360\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : aeon113 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8d34\u4e00\u4e0b\u4f60\u7684\u4ee3\u7801\u548c\u7f16\u8bd1\u9009\u9879\u5427<\/p>\n<p>malloc \u6267\u884c\u8fc7\u7a0b\u4e2d\u662f\u6709\u53ef\u80fd\u4f1a\u8fdb\u5165\u5230\u5185\u6838\u6001\u7684\uff0c\u5e76\u4e14\uff0c\u6211\u8bb0\u5f97\u5728 Linux \u4e2d\uff0c\u7ed9\u7528\u6237\u8fdb\u7a0b\u5206\u914d\u51fa\u7684\u865a\u62df\u5730\u5740\u4e8b\u5b9e\u4e0a\u5e76\u6ca1\u6709\u5bf9\u5e94\u7269\u7406\u5185\u5b58\uff0c\u7269\u7406\u5730\u5740\u4f1a\u5728\u76ee\u6807 page \u7b2c\u4e00\u6b21\u88ab\u8bbf\u95ee\u65f6\u5206\u914d\u3002\u8fd9\u4e2a\u53ef\u80fd\u4f1a\u9020\u6210\u8fdb\u7a0b\u5728\u5199\u5165\u5927\u6570\u7ec4\u65f6\u53c8\u591a\u6b21\u9677\u5165\u5185\u6838\u6001\u3002<br \/>\u53ef\u4ee5\u5c1d\u8bd5 malloc \u4e00\u6b21\uff0c\u7136\u540e\u591a\u5199\u51e0\u6b21\uff0c\u4e22\u6389\u7b2c\u4e00\u6b21\u5199\u5165\u7684\u6d4b\u8bd5\u6570\u636e\uff0c\u7528\u5269\u4e0b\u7684\u5199\u5165\u5ef6\u8fdf\u7b97\u51fa\u4e00\u4e2a\u5e73\u5747\u503c\u505a\u7ed3\u679c\u3002<\/p>\n<p>\u53e6\u5916\uff0c\u8fd9\u91cc\u6808\u4e0a\u7684\u5199\u5165\u8fc7\u7a0b\u76f8\u5f53\u4e8e\u5bf9\u540c\u4e00\u6bb5\u6808\u5185\u5b58\u5199\u5165\u4e86 10000 \u6b21\u3002\u5982\u679c\u4e0d\u662f\u7528 memset \u6765\u5199\u7684\u8bdd\uff0c\u90a3\u6709\u53ef\u80fd\u524d 9999 \u6b21\u5168\u90e8\u88ab\u4f18\u5316\u6389\u4e86\u53ea\u5269\u4e0b\u4e86\u6700\u540e\u4e00\u6b21\u3002\u8fd9\u4e2a\u5f97\u770b\u7f16\u8bd1\u5668\u7684\u751f\u6210\u7ed3\u679c\u624d\u80fd\u786e\u5b9a\u3002<\/p>\n<p>\u6570\u7ec4\u5927\u5c0f\u4e0d\u540c\uff0c\u5360\u7528\u7684 CPU cache line \u6570\u91cf\u4e5f\u4e0d\u540c\u3002\u4e00\u5757 CPU \u4e0d\u662f\u53ea\u6709\u4e00\u4e2a\u8fdb\u7a0b\u5728\u4f7f\u7528\uff0c\u6bcf\u4e2a\u8fdb\u7a0b\u5bf9\u5185\u5b58\u7684\u6bcf\u6b21\u8bfb\u5199\u90fd\u53ef\u80fd\u9020\u6210\u67d0\u4e2a cache line \u5185\u7684\u539f\u6570\u636e\u88ab\u5237\u51fa\uff0c\u65b0\u6570\u636e\u88ab\u8bfb\u5165\u3002\u90a3\u4e48\u6570\u636e size \u8d8a\u5927\uff0c\u5360\u7528\u7684 cache line \u8d8a\u591a\uff0c\u5176\u5185\u90e8\u5206\u6570\u636e\u88ab\u5237\u51fa\u7684\u6982\u7387\u4e5f\u5c31\u8d8a\u9ad8\uff0c\u76f8\u5bf9\u6027\u80fd\u4e5f\u5c31\u4f1a\u66f4\u5dee\u4e00\u4e9b\u3002<\/p>\n<p>\u6700\u540e\uff0c\u5982\u679c\u673a\u5668\u5185\u5b58\u4e0d\u5927\u7684\u8bdd\uff0c\u8bbf\u95ee\u5806\u5185\u5b58\u65f6\u4e5f\u53ef\u80fd\u4f1a\u56e0\u4e3a swap \u548c\u5237 dirty page \u635f\u5931\u4e0d\u5c11\u6027\u80fd\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609361\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : hyyou2010 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             1\uff0c\u6808\u589e\u52a0\u662f\u7d22\u5f15\u5730\u5740\u52a0\u52a0\uff0c\u6808\u5f52\u8fd8\u5c31\u662f\u7d22\u5f15\u5730\u5740\u51cf\u51cf\uff0c\u51e0\u4e4e\u6ca1\u6709\u66f4\u5feb\u7684\u7a7a\u95f4\u5206\u914d\u65b9\u5f0f<br \/>2\uff0c\u5806\u5206\u914d\u7a7a\u95f4\u5219\u662f\u4ece\u6574\u4e2a\u5806\u7a7a\u95f4\u5bfb\u627e\u4e00\u7247\u5408\u9002\u7684\uff0c\u8fd9\u4e2a\u5e76\u4e0d\u7b80\u5355\uff0c\u8981\u9632\u6b62\u7a7a\u95f2\u7a7a\u95f4\u6210\u788e\u7247\u4ee5\u81f3\u4e8e\u540e\u7eed\u65e0\u6cd5\u4f7f\u7528\u3002\u5f52\u8fd8\u65f6\u8fd8\u5f97\u5408\u5e76\u7a7a\u95f2\u7a7a\u95f4\uff0c\u4e5f\u662f\u4e00\u7b14\u5f88\u5927\u7684\u5f00\u652f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609362\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : IsaacYoung <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             sbrk \u66f4\u65b0\u9875\u8868                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609363\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : kejialiu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u8fd8\u6709\u5bc4\u5b58\u5668\u4f18\u5316\u3002C \u8bed\u8a00\u5f88\u591a\u5c40\u90e8\u53d8\u91cf\u539f\u5219\u4e0a\u662f\u5206\u914d\u5728\u6808\u4e0a\uff0c\u4f46\u7f16\u8bd1\u5668\u4f18\u5316\u540e\u76f4\u63a5\u653e\u901a\u7528\u5bc4\u5b58\u5668\u5c31\u597d\u4e86\uff0c\u90fd\u4e0d\u9700\u8981\u8fdb\u5185\u5b58                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609364\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : iceheart <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4ee5\u4e0a\u4e00\u4e2a\u7b54\u5bf9\u7684\u90fd\u6ca1\u6709\u3002<br \/>\u6808\u6bd4\u5806\u5feb\u53ea\u6709\u4e00\u4e2a\u539f\u56e0: \u6808\u4e00\u76f4\u5728\u8bbf\u95ee\uff0c\u6ca1\u6709\u673a\u4f1a\u88ab\u6362\u51fa cpu \u7f13\u5b58\uff0c\u6240\u4ee5\u6808\u5185\u5b58\u8bbf\u95ee\u603b\u662f\u9ad8\u901f\u7f13\u5b58\u547d\u4e2d\uff0c\u5feb 30 \u500d\u662f cpu \u9ad8\u901f\u7f13\u5b58\u4e0e\u5185\u5b58\u5b9e\u9645\u8bbf\u95ee\u901f\u5ea6\u7684\u5dee\u8ddd                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609365\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : irytu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5806\u5185\u5b58\u5206\u914d\u633a\u590d\u6742\u7684 \u6709\u53ef\u80fd\u4f1a trap \u5230\u5185\u6838\u91cc \u5728\u5730\u5740\u7a7a\u95f4\u4e0d\u591f\u7684\u60c5\u51b5\u4e0b \u9700\u8981 sbrk syscall \u6765\u589e\u957f \u7136\u540e\u7b2c\u4e00\u6b21\u8bbf\u95ee\u7684\u65f6\u5019 page fault\uff0c\u5176\u5b9e\u6808\u4e5f\u6709\u7c7b\u4f3c\u7684\u60c5\u51b5\u5982\u679c\u6ca1\u7406\u89e3\u9519 \u6808\u7684\u4e0d\u591f\u7528\u4e86 \u4e5f\u4f1a trigger \u4e00\u6b21 page fault \u66f4\u65b0 page table \u76f4\u5230 stack overflow \uff1f                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609366\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : irytu <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u521a\u521a\u67e5\u4e86\u4e00\u4e0b \u4f3c\u4e4e sbrk \u8fd9\u4e2a syscall \u6e10\u6e10\u88ab\u5e9f\u5f03\u4e86 \u7528 mmap(2) \u53d6\u800c\u4ee3\u4e4b                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609367\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gyf304 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4f60\u8fd9\u4e2a\u63a7\u5236\u53d8\u91cf\u90fd\u6ca1\u6709\uff0cheap \u6bd4 stack \u5927\u90a3\u4e48\u591a\uff0ccache miss \u80af\u5b9a\u5f88\u4e25\u91cd\u554a\u3002<br \/>\u8fd8\u6709\u5c31\u662f\u5982\u4e0a\u9762\u8bf4\u7684\uff0cmmap \u8981\u7ecf\u8fc7\u5185\u6838\uff0c\u521d\u6b21\u5199\u5165\u88ab\u5206\u914d\u7684\u9875\u7684\u65f6\u5019\u4e5f\u662f\u662f\u8981 page fault \u7684\uff0c\u4e5f\u662f\u8981\u8fc7\u5185\u6838\u7684\u3002<br \/>\u5efa\u8bae\u8bfb\u4e00\u4e0b\u300a CS:APP \u300b\u5173\u4e8e\u5185\u5b58\u7684\u5185\u5bb9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609368\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gyf304 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @2435043xia \u6808\u548c\u5806\u5185\u5b58\u7269\u7406\u4e0a\u662f\u6ca1\u6709\u533a\u522b\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609369\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gyf304 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @godblessumilk <br \/>\u6211\u4e2a\u4eba\u8ba4\u4e3a\u7528\u6bd4\u55bb\u7684\u65b9\u5f0f\u5b66\u4e60\u662f\u6bd4\u8f83\u7cdf\u7cd5\u7684\u65b9\u5f0f\u3002\u5165\u95e8\u53ef\u4ee5\uff0c\u62ff\u6765\u89e3\u91ca\u4e1c\u897f\u4e0d\u592a\u59a5\u5f53\u3002\u201c\u56e0\u4e3a A \u50cf B\uff0c\u6240\u4ee5\u6211\u4eec\u7528 B \u6765\u89e3\u91ca A\u201d\u662f\u4e0d\u5408\u903b\u8f91\u7684\u3002<br \/>\u5806\u548c\u6808\u5185\u5b58\u5728\u7269\u7406\u4e0a\u662f\u6ca1\u6709\u533a\u522b\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609370\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : geelaw <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u4e3a\u4ec0\u4e48\u4e0a\u90fd\u6709\u8fd9\u4e48\u591a\u7b54\u6848\u2026<\/p>\n<p>\u8fd9\u4e2a\u95ee\u9898\u4f1a\u56e0\u4e3a\u4e3b\u4f7f\u7528\u4e86\u4f55\u79cd C \u8bed\u8a00\u7f16\u8bd1\u5668\u3001\u5982\u4f55\u7533\u8bf7\u7684\u5806\u5185\u5b58\u6709\u5343\u5947\u767e\u602a\u7684\u7b54\u6848\u3002\u5982\u679c\u4e3b\u7528\u7684 malloc \u5185\u90e8\u7ef4\u62a4\u4e00\u4e2a\u7ed3\u6784\uff0c\u4e14\u4f18\u5148\u8003\u8651\u76f4\u63a5\u5206\u914d\u521a\u521a\u91ca\u653e\u7684\u5185\u5b58\uff0c\u4e14\u6ca1\u6709\u53d1\u751f\u4f18\u5316\uff0c\u662f\u4e0d\u53ef\u80fd\u4f1a\u6709\u8fd9\u4e48\u5927\u7684\u5dee\u522b\u7684\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609371\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : xiadong1994 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u53ef\u80fd\u7684\u5f71\u54cd\u592a\u591a\u4e86\uff0c\u7f16\u8bd1\u5668\u4f18\u5316\uff0cmalloc \u5b9e\u73b0\u90fd\u6ca1\u8003\u8651\u3002\u5148\u770b\u770b\u4f18\u5316\u540e\u7684\u6c47\u7f16\u662f\u4e0d\u662f\u4f60\u60f3\u7684\u90a3\u6837\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609372\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : myy1966 <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/github.com\/spuhpointer\/stack-vs-heap-benchmark<br \/>\u90fd\u5e26\u6570\u636e\u521d\u59cb\u5316\u7684\u8bdd\uff0c\u5806\u548c\u6808\u7684\u901f\u5ea6\u51e0\u4e4e\u4e00\u6837\u3002\u4f60\u5bf9\u6808\u7684\u7a0b\u5e8f\u8ddf\u5806\u4e0d\u540c\uff0c\u6808\u4e0a\u5728\u5faa\u73af\u91cc\u521b\u5efa\u6570\u7ec4\u7684\u8bdd\u6bcf\u6b21\u5230\u4e0b\u4e00\u4e2a\u5faa\u73af\u4f1a\u628a\u4e0a\u4e00\u6b21\u521b\u5efa\u7684\u6570\u636e\u9500\u6bc1\uff0c\u7136\u540e\u91cd\u65b0\u521b\u5efa\u6570\u7ec4\uff0c\u8fd9\u6837\u4f60\u7684\u6570\u7ec4\u5b9e\u9645\u4e0a\u4e00\u76f4\u5728\u4f7f\u7528\u4e00\u5757\u76f8\u540c\u7684\u5185\u5b58\u7a7a\u95f4\uff0c\u8fd9\u589e\u5927\u4e86\u7f13\u5b58\u547d\u4e2d\u7684\u6982\u7387\u3002\u800c\u4f60\u7684\u5806\u7684\u7a0b\u5e8f\u76f4\u63a5\u521b\u5efa\u4e86\u957f\u5ea6\u4e3a 1 \u4ebf\u7684\u6570\u636e\uff0c\u8fd9\u6837\u8fde\u7eed\u7684\u8bbf\u5b58\u4f1a\u4ea7\u751f\u5f88\u591a\u7f13\u5b58\u4e0d\u547d\u4e2d\uff0c\u964d\u4f4e\u4e86\u6027\u80fd\u3002\u516c\u5e73\u7684\u5bf9\u6bd4\u529e\u6cd5\u662f\u624b\u52a8\u628a\u64cd\u4f5c\u7cfb\u7edf\u9884\u8bbe\u7684\u6808\u5927\u5c0f\u6539\u5927\u5230\u53ef\u4ee5\u5bb9\u4e0b 1 \u4ebf\u957f\u5ea6\u7684\u6570\u7ec4\uff0c\u7136\u540e\u5728\u6808\u7684\u6d4b\u8bd5\u4e2d\u76f4\u63a5\u521b\u5efa\u957f\u5ea6\u4e3a 1 \u4ebf\u7684\u6570\u7ec4\uff0c\u8fd9\u6837\u6d4b\u8bd5\u51fa\u6765\u7684\u6027\u80fd\u5806\u548c\u6808\u5e94\u8be5\u662f\u5dee\u4e0d\u591a\u7684\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609373\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 3dwelcome <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             &#8220;`<br \/>double* test1 = new double[10000*10000];<br \/>for (int i=0;i&lt;10000*10000;i++)<br \/> test1[i] = 0;<br \/>&#8220;`<\/p>\n<p>&#8220;`<br \/>double* test2 = (double*)alloca(10000);<br \/>for (int y=0;y&lt;10000;y++)<br \/>for (int x=0;x&lt;10000;x++)<br \/>{<br \/> test2[i] = 0;<br \/>}<br \/>&#8220;`<\/p>\n<p>\u6211\u7684\u5806 \/\u6808\u6d4b\u8bd5\u4ee3\u7801\uff0ctest1 \u5806\u8fd0\u884c\u5b8c\u662f 0.4s, test2 \u6808\u662f 0.2s \uff0c\u5f88\u7b26\u5408\u81ea\u5df1\u76f2\u731c\u7ed3\u679c\u3002\u54ea\u6709\u4e3b\u8bf4\u7684 30 \u500d\u5dee\u8ddd\uff0c\u80af\u5b9a\u662f\u6709\u4ec0\u4e48 bug \u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609374\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 3dwelcome <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @gyf304 &#8220;\u6808\u548c\u5806\u5185\u5b58\u7269\u7406\u4e0a\u662f\u6ca1\u6709\u533a\u522b\u7684&#8221;, CPU L1\/L2 \u9ad8\u901f\u7f13\u5b58\u548c\u666e\u901a\u5185\u5b58\u5730\u5740\u8bbf\u95ee\uff0c\u901f\u5ea6\u533a\u522b\u5de8\u5927\u3002                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609375\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : dalabenba <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @3dwelcome cache \u5bf9\u4e8e cpu \u8bbf\u95ee\u5185\u5b58\u662f\u900f\u660e\u7684\uff0c\u6808\u548c\u5806\u53ea\u4e0d\u8fc7\u662f\u8fdb\u7a0b\u5730\u5740\u7a7a\u95f4\u5212\u5206\u7684\u4e24\u4e2a\u90e8\u5206\uff0c\u4e0b\u9762\u6620\u5c04\u7684\u7269\u7406\u5185\u5b58\u90fd\u662f\u4e00\u6837\u7684                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609376\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : 3dwelcome <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @dalabenba \u597d\u50cf\u4f60\u4eec\u8bf4\u7684\u5bf9\u3002<br \/>\u6211 test2 \u4ee3\u7801\u91cc\uff0c\u628a alloca(10000)\u6362\u6210\u4e86 malloc(10000)\uff0c\u4e24\u8005\u7528\u65f6\u7ed3\u679c\u662f\u4e00\u6837\u7684\u3002<br \/>\u539f\u6d4b\u8bd5 test1 \u6162\uff0c\u53ef\u80fd\u5c31\u662f\u5bfb\u5740\u5185\u5b58\u8fc7\u5927\uff0ccache miss \u5bfc\u81f4\u7684\u3002<\/p>\n<p>\u672c\u6765\u4ee5\u4e3a alloca \u5206\u914d\u7684\u5730\u5740\uff0c\u66f4\u63a5\u8fd1\u8fd0\u884c\u4ee3\u7801\u5757\uff0c\u5c31\u66f4\u5bb9\u6613\u88ab cpu cache\uff0c\u901f\u5ea6\u5c31\u66f4\u5feb\u3002\u4e5f\u8bb8\u770b cpu \u5fc3\u60c5\u624d\u662f\u6700\u91cd\u8981\u7684\u3002                                                            <\/p><\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609377\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : Claar <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u6808\u7684\u7533\u8bf7\u5728\u7f16\u8bd1\u671f\u5df2\u7ecf\u786e\u5b9a\uff0c\u53ea\u662f esp \u548c ebp \u7684\u504f\u79fb\u3002\u5806\u7684\u7533\u8bf7\u672c\u8eab\u662f\u5728\u4e00\u4e2a\u5927\u8303\u56f4\u7a7a\u95f2\u5185\u5b58\u4e2d\u8fdb\u884c\u7a7a\u95f4\u7533\u8bf7\uff0c\u8fd9\u6d89\u53ca\u5230 glibc \u5982\u4f55\u57fa\u4e8e\u5f53\u524d\u60c5\u51b5\u5206\u914d\u7684\u95ee\u9898(\u5982\u4f55\u6574\u7406\u73b0\u6709\u7684\u5c0f\u5185\u5b58\u7b49\u64cd\u4f5c)\uff0c\u662f\u4e00\u4e2a\u4e0d\u7b97\u7b80\u5355\u7684\u8fc7\u7a0b\uff0c\u8be6\u60c5\u53ef\u4ee5\u53bb\u770b\u770b ctfwiki \u4e2d\u5173\u4e8e pwn \u4e0b linux \u7684\u5806\u7ba1\u7406\u5668\u7684\u8bb2\u89e3\uff0c\u6216\u8005\u76f4\u63a5\u770b glibc \u7684\u6e90\u7801\u91cc\u5173\u4e8e int_malloc \u7684\u90e8\u5206                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"5609378\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : wellsc <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @godblessumilk \u793e\u6b7b\u73b0\u573a                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u4f7f\u7528\u5806\u5185\u5b58\u4e3a\u4ec0\u4e48\u6bd4\u6808\u5185\u5b58\u6162\u5f88\u591a\u5f88\u591a&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/420130"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=420130"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/420130\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=420130"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=420130"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=420130"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}