×÷?a.NET???×?úèYμ?ò?2?·?£?à?????ê??÷(?ò3?GC)ê?±?D?á??aμ??úèY?£±?×??°í¨?×ò×???±μ??-?ò£?±??????aêíCLR?Dà?????ê??÷μ?1¤×÷?-àí?£
?ù′??aê?
íD1ü??(Managed Heap)
?èà′?′MSDNμ??aêí£o3?ê??ˉD???3ìê±£???DDê±?á?a??3ì±£á?ò???á?D?μ?μ??·??????óò?£?a??±£á?μ?μ??·????±?3??aíD1ü???£
?°íD1ü??ò2ê????±£??aê2?′?a?ù?μ??£??a?′?μê??£í?′ó?ò2?òa±??°ê?ó??±???ó£??a???aê?μ?μ??°ìáê??°?μààDíoíòyó?ààDíμ???±e?±?£?aà??ùéè?á??ò??-?aμà?°?μààDí′?′¢?ú???D£?òyó?ààDí′?′¢?ú???D?£(òyó?ààDíμ?òyó?′?′¢?ú???D)?±?aò???òa?????£?ùò?£??ù?Y?a??àí??£?3y?μààDíía£?CLRòa?ó?ùóD×ê?′??′óíD1ü??·????£
íD1ü?????¤×?ò???????£??aà??ü???aNextObjPtr£??ü???ò??ò??????ó?ú???Dμ?·????????£
CPU??′??÷(CPU Register)
?a??ê??????ú?ù′??aê?£??aà??′?°ò???£?óD?úóú???????°?ù?±????μ?àí?a?£
CPU??′??÷ê?CPU×??oμ??±áùê±′?′¢?÷?±,±è?ú′?μ?′?è??1?ì?£°′ó?CPU???üà′·?£?à?μ?×??üμ?ê???′??÷£?è?oó?o′?(?????úò??¢?t?¢èy???o′?)£?×?oó?ú′??£
?ù(Roots)
àà?D?¨ò?μ?è?o??2ì?×???£?·?·¨μ?2?êy£???2?±?á?(???Tòyó?ààDí±?á?)μè??ê??ù£?áííacpu??′??÷?Dμ????ó????ò2ê??ù?£?ùê?CLR?ú????ía?éò??òμ?μ??÷??è??úμ??£
???ó?é′?ó?2??é′?(Objects reachable and unreachable)
è?1?ò????ùòyó?á????Dμ?ò??????ó£??ò?????ó?a?°?é′??±£?·??ò?′ê??°2??é′??±?£
à?????ê?μ??-òò
′ó?????ú×é3éμ????èà′?2£??ùóDμ?3ìDò??ê?òaפá??ú?ú′??D??DDμ??£???ú′?ê?ò????T??òò??(′óD?)?£3y′???ía£?íD1ü??ò2óD′óD??T???£è?1?íD1ü????óD′óD??T??£???C#μ??′DD?ù?èòaó?óúcá?(íD1ü??μ??á11è??üóD±èc??DDê±???ü?ìμ????ó·????ù?è)?£òò?aμ??·????oí′?′¢μ??T??òò??£?íD1ü??òaí¨1yà?????ê??ú??£?à′??3??üμ??y3£??×÷£?±£?¤???óμ?·???£?2??á?°?ú′?ò?3??±?£
à?????ê?μ??ù±??-àí
??ê?·??aá????×??£o ±ê?? ¨C> ?1??
±ê??μ?1y3ì£???êμ?íê??D?????óê?·??é′?μ?1y3ì?£μ±?ùóDμ??ù???ì2éíê±?oó£????D??°üo??é′?(ò?±ê??)ó?2??é′?(?′±ê??)???ó?£
±ê??íê3éoó£???è??1???×???£?ú?a???×???D£?à?????ê??÷??D?μ?±éàú??£?ò??°?ò2??é′????óμ?á?D??ú′??é?£2¢°??é′????óò??ˉμ??aà?ò??1?????£?a??1y3ìóDμ?àà??óú′??ì????μ??é????àí?£
è?é?í??ùê?£??ìé??ò±íê??é′????ó£???é??ò?a2??é′????ó?£2??é′????ó??3yoó£?ò??ˉ?é′????óêμ???ú′??1??(±?μ??ü??′?)?£
?1????oó£??°???ò?aD????óμ??????±μ?±?á?oíCPU??′??÷???ú???áê§D§£?à?????ê??÷±?D???D?·??ê?ùóD?ù£?2¢DT???ü??à′???ò???óμ?D??ú′??????£?a?á?ì3é????μ?D??ü?eê§?£?a???eê§ò2ê?íD1ü??μ??÷òaè±μ??£
?ùóúò?é?ì?μ?£?à?????ê?òy·¢μ???ê???·¨ò2ê?ò????D????ìa?£òò?aè?1???μèμ?íD1ü???ú2??aê??′DDà?????ê?£????í??μ?ì??°?y?±á??£
à?????ê???·¨ ¨C ·?′ú(Generation)??·¨
′úê?CLRà?????ê??÷2éó?μ?ò????ú??£??ü?¨ò?μ???μ??íê?ìáéyó|ó?3ìDòμ?D??ü?£·?′ú??ê?£??ù?è??è??ìóú??ê????????£
CLRíD1ü???§3?3′ú£oμú0′ú£?μú1′ú£?μú2′ú?£μú0′úμ????????a256KB£?μú1′ú???a2M£?μú2′ú???a10M?£D?11?ìμ????ó?á±?·???μ?μú0′ú?£
è?é?í??ùê?£?μ±μú0′úμ??????úê±£?à?????ê??÷???ˉ??ê?£?2??é′????ó(é?í?C?¢E)?á±???ê?£?′???μ????ó±?1é?aμú1′ú?£
μ±μú0′ú????ò??ú£?μú1′úò2?aê?óDoü?à2??é′????óò??á???????úê±£??aê±á?′úà???????±???ê??£′?????à′μ????ó(?é′????ó)£?μú0′úéy?aμú1′ú£?μú1′úéy?aμú2′ú?£
êμ?êCLRμ?′ú??ê??ú???ü?ó?°???ü?±£?è?1?D?′′?¨μ????óéú′??ü?úoü?ì£?μú0′úà???ò2?áá¢?ì±?à?????ê??÷??ê?(2?ó?μè????·????ú)?£áíía£?è?1???ê?á?μú0′ú£?·¢???1óDoü?à???ó?°?é′??±£?
2¢??óDêí·??àéù?ú′?£??í?á??′óμú0′úμ??¤???á512KB£???ê?D§1??í?á×a±??a£oà?????ê?μ?′?êy????éù£?μ???′????á??ê?′óá?μ??ú′??£è?1??1??óDêí·??àéù?ú′?£?à?????ê??÷???′DD
íêè???ê?(3′ú)£?è?1??1ê?2?1?£??ò?á?×3??°?ú′?ò?3??±òì3£?£
ò2?íê??μ£?à?????ê??÷?á?ù?Y??ê??ú′?μ?′óD?£??ˉì?μ?μ÷????ò?′úμ?·????????¤??£?′?μ?×??ˉó??ˉ£?
×ü?á
à?????ê?±3oóóD?a?ùò????ù±?μ?1???£o±à3ìó???(′ó?àêyμ?)??o?×ü?ü·??ê?T?Tμ??ú′??£???a·¢???éò?ò??±·????¢·????ù·????a?a???§·¨ò??ù£?è???2???ó???2????£
.NETà?????ê??÷μ??ù±?1¤×÷?-àíê?£oí¨1y×??ù±?μ?±ê????3y?-àí£???3y2??é′????ó£??ù??′??ì?é????àíò??ù?1???¢??àí?éó??ú′?£?×?oóí¨1y·?′ú??·¨êμ??D??ü×?ó??ˉ?£