{"id":414,"date":"2022-08-06T15:36:10","date_gmt":"2022-08-06T07:36:10","guid":{"rendered":"https:\/\/www.db2go.net\/?p=414"},"modified":"2022-08-06T15:36:10","modified_gmt":"2022-08-06T07:36:10","slug":"mheap","status":"publish","type":"post","link":"https:\/\/www.db2go.net\/?p=414","title":{"rendered":"mheap"},"content":{"rendered":"<pre><code class=\"line-numbers\">type mheap struct {\n    lock      mutex                    \/\/ \u662f\u516c\u6709\u7684\uff0c\u9700\u8981\u52a0\u9501\n    free      [_MaxMHeapList]mSpanList \/\/ \u672a\u5206\u914d\u7684spanlist\uff0c\u6bd4\u5982free[3]\u662f\u7531\u5305\u542b3\u4e2a page \u7684 mspan \u7ec4\u6210\u7684\u94fe\u8868   \n    freelarge mTreap                   \/\/ mspan\u7ec4\u6210\u7684\u94fe\u8868\uff0c\u6bcf\u4e2amspan\u7684 page \u4e2a\u6570\u5927\u4e8e_MaxMHeapList\n    busy      [_MaxMHeapList]mSpanList \/\/ busy lists of large spans of given length\n    busylarge mSpanList                \/\/ busy lists of large spans length &gt;= _MaxMHeapList\n    allspans []*mspan                  \/\/ \u6240\u6709\u7533\u8bf7\u8fc7\u7684 mspan \u90fd\u4f1a\u8bb0\u5f55\u5728 allspans\n    spans []*mspan                     \/\/ \u8bb0\u5f55 arena \u533a\u57df\u9875\u53f7\uff08page number\uff09\u548c mspan \u7684\u6620\u5c04\u5173\u7cfb\n\n    arena_start uintptr \/\/ arena\u662fGo\u4e2d\u7528\u4e8e\u5206\u914d\u5185\u5b58\u7684\u8fde\u7eed\u865a\u62df\u5730\u5740\u533a\u57df\uff0c\u8fd9\u662f\u8be5\u533a\u57df\u5f00\u59cb\u7684\u6307\u9488\u3002\u4e5f\u662f\u5c06\u8981\u5206\u914d\u7ed9\u5e94\u7528\u7a0b\u5e8f\u4f7f\u7528\u7684\u7a7a\u95f4\n    arena_used  uintptr \/\/ \u5df2\u7ecf\u4f7f\u7528\u7684\u5185\u5b58\u7684\u6307\u9488\n    arena_alloc uintptr\n    arena_end   uintptr\n\n  \/\/arenas\u6570\u7ec4\u96c6\u5408,\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\n   arenas [1 &lt;&lt; arenaL1Bits]*[1 &lt;&lt; arenaL2Bits]*heapArena\n\n  \/\/\u5404\u4e2a\u89c4\u683c\u7684mcentral\u96c6\u5408\n    central [numSpanClasses]struct {\n        mcentral mcentral\n        pad      [sys.CacheLineSize - unsafe.Sizeof(mcentral{})%sys.CacheLineSize]byte \/\/\u907f\u514d\u4f2a\u5171\u4eab\uff08false sharing\uff09\u95ee\u9898\n    }\n\n    spanalloc             fixalloc \/\/ allocator for span*\n    cachealloc            fixalloc \/\/ mcache\u5206\u914d\u5668\n}\n<\/code><\/pre>\n<p>\u5bf9\u4e8e<code>runtime.mheap<\/code>\u9700\u8981\u5173\u6ce8central\u548carenas\u3002central\u662f\u5404\u4e2a\u89c4\u683c\u7684mcentral\u96c6\u5408\uff0c\u5728\u521d\u59cb\u5316\u7684\u65f6\u5019\u4f1a\u901a\u8fc7\u904d\u5386class_to_size\u6765\u8fdb\u884c\u521b\u5efa\uff1barenas\u662f\u4e00\u4e2a\u4e8c\u7ef4\u6570\u7ec4\uff0c\u7528\u6765\u7ba1\u7406\u5185\u5b58\u7a7a\u95f4\u3002arenas\u7531\u591a\u4e2a<code>runtime.heapArena<\/code>\u7ec4\u6210\uff0c\u6bcf\u4e2a\u5355\u5143\u90fd\u4f1a\u7ba1\u7406 64MB \u7684\u5185\u5b58\u7a7a\u95f4\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>type mheap struct { lock mutex \/\/ \u662f\u516c\u6709\u7684\uff0c\u9700\u8981\u52a0\u9501 free [_MaxM&hellip;<\/p>\n <a href=\"https:\/\/www.db2go.net\/?p=414\" title=\"mheap\" class=\"entry-more-link\"><span>Read More<\/span> <span class=\"screen-reader-text\">mheap<\/span><\/a>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"Layout":"","footnotes":""},"categories":[12],"tags":[],"class_list":["entry","author-suredandan","post-414","post","type-post","status-publish","format-standard","category-golang"],"views":1330,"_links":{"self":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/414","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=414"}],"version-history":[{"count":1,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/414\/revisions"}],"predecessor-version":[{"id":416,"href":"https:\/\/www.db2go.net\/index.php?rest_route=\/wp\/v2\/posts\/414\/revisions\/416"}],"wp:attachment":[{"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=414"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=414"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.db2go.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=414"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}