最近看到一篇文章,是介绍CLR内部是如何创建运行时对象的.感觉写的很不错,特此保存.虽然原贴针对的是.net framework1.1版本,但设计思想应该是可以延续的. 为了以后检索起来方便,做一点阅读笔记

原贴地址:英文         中文

目录结构:

术语表
Domains Created by the CLR Bootstrap
System Domain
SharedDomain
DefaultDomain
LoaderHeaps
Non-LoaderHeaps

文章中用到的主要术语

  • Domains Created by the CLR Bootstrap:System Domain , Shared Domain, Default AppDomain
  • CLR Hosts: Simple host,i.e a console program; Complicated host, i.e. ASP.NET
  • LoaderHeaps : GC Heap hosts object instances while LoaderHeaps hold together the type system. Including:
    1. HighFrequencyHeap(MethodTables, MethodDescs, FieldDescs, and Interface Maps)
    2. LowFrequencyHeap(EEClass and ClassLoader and its lookup tables)
    3. StubHeap(hosts stubs that facilitate code access security (CAS), COM wrapper calls, and P/Invoke.)
  • Type Fundamentals
  • GC Heap, Large Object Heap; JIT Heap; Process Heap
  • ObjectInstance --> TypeHandle VS
  • MethodTable&EEClass == Type
  • Interface Vtable Map and Interface Map
  • Method Descriptor (MethodDesc)
  • Virtual Dispatch
  • Static Variables

Domains Created by the CLR Bootstrap

Figure 1 Domains Created by the CLR Bootstrap

Before the CLR executes the first line of the managed code, it creates three application domains. Two of these are opaque from within the managed code and are not even visible to CLR hosts. They can only be created through the CLR bootstrapping process facilitated by the shim—mscoree.dll and mscorwks.dll (or mscorsvr.dll for multiprocessor systems)

System Domain and the Shared Domain, which are singletons;Default AppDomain, an instance of the AppDomain class that is the only named domain

using the AppDomain.CreateDomain with managed code or ICORRuntimeHost interface within unmanged code to create other AppDomain

System Domain

  • responsible for creating and initializing the SharedDomain and the default AppDomain
  • loads the system library mscorlib.dll into SharedDomain
  • keeps process-wide string literals interned implicitly or explicitly
  • generating process-wide interface IDs(used in creating InterfaceVtableMaps )
  • keeps track of all the domains in the process
  • implements functionality for loading and unloading the AppDomains

SharedDomain

  • load domain-neutral code,such as mscorlib
  • load Fundamental types from the System namespace during the CLR bootstrapping process
    1. Object, ValueType, Array, Enum, String, and Delegate
  • using System.LoaderOptimizationAttribute, user code can also be loaded into SharedDomain
  • manages an assembly map indexed by the base address
    1. acts as a lookup table for managing shared dependencies of assemblies being loaded into DefaultDomain and of other created AppDomains

DefaultDomain

  • an instance of AppDomain
  • load non-shared user code,within which application code is typically executed
  • cross-domain access will occur through .NET Remoting proxies
  • Each AppDomain has the following data structs:
    1. loader heaps (High-Frequency Heap, Low-Frequency Heap, and Stub Heap)
    2. Handle Tables (Handle Table, Large Object Heap Handle Table)
    3. Interface Vtable Map Manager
    4. Assembly Cache

LoaderHeaps

  • loading  runtime CLR artifacts and optimization artifacts that live for the lifetime of the domain
  • different from the garbage collector (GC) Heap:
    1. GC Heap hosts object instances
    2. LoaderHeaps hold together the type system
  • HighFrequencyHeap, contains frequently accessed artifacts:
    1. MethodTables
    2. MethodDescs
    3. FieldDescs
    4. Interface Maps
  • LowFrequencyHeap, contains less frequently accessed data structures:
    1. EEClass
    2. ClassLoader and its lookup tables
  • StubHeap, contains stubs that facilitate code access security (CAS), COM wrapper calls, and P/Invoke.
  • Each domain has a InterfaceVtableMap (referred to here as IVMap) that is created on its own LoaderHeap during the domain initialization phase
  • size for each heap:
    1. HighFrequencyHeap initial reserve size is 32KB and its commit size is 4KB
    2. LowFrequencyHeap and StubHeaps are initially reserved with 8KB and committed at 4KB
    3. The IVMap heap is reserved at 4KB and is committed at 4KB initially

Non-LoaderHeaps

  • Process Heap
  • JIT Code Heap
  • GC Heap (for small objects)
  • Large Object Heap (for objects with size 85000 or more bytes)
  • The just-in-time (JIT) compiler generates x86 instructions and stores them on the JIT Code Heap
  • GC Heap and Large Object are the garbage-collected heaps on which managed objects are instantiated.
    1. LOH is not compacted, GC Heap(or called normal GC Heap) is compacted whenever a GC collection occurs
    2. LOH is only collected on full GC collections

How the CLR Creates Runtime Objects相关推荐

  1. What is Type in managed heap?

    我们知道,在程序运行过程中,每个对象(object)都是对应了一块内存,这里的对象不仅仅指的是某个具体类型的实例(instance),也包括类型(type)本身.我想大家也很清楚CLR如何为我们创建一 ...

  2. [你必须知道的.NET]第十九回:对象创建始末(下)

    本文将介绍以下内容: 对象的创建过程 内存分配分析 内存布局研究 接上回[第十八回:对象创建始末(上)],继续对对象创建话题的讨论>>> 2.2 托管堆的内存分配机制 引用类型的实例 ...

  3. 解读.net垃圾回收和CLR 4.0对垃圾回收所做的改进之一-.Net编程教程

    解读.net垃圾回收和CLR 4.0对垃圾回收所做的改进之一-.Net编程教程 来源:模板无忧 作者:编辑整理更新时间:2009-07-19点击:114 A survey of garbage col ...

  4. 安卓9可用的性能监视器_监视应用程序生态系统的性能和可用性

    在这个三篇文章的系列的第1部分和第2部分中 ,我介绍了监视Java应用程序的技术和模式,重点是JVM和应用程序类. 在最后的最后一部分中,我将重点放在介绍用于从应用程序的依赖项(例如底层操作系统,网络 ...

  5. java内存问题排查及分析

    最近了解了一下jdk对于jvm分析工具的使用,下面通过一个简单的列子介绍一下,以下内容部分来自其他帖子. 下面这段代码明显有问题(从网上抄的) 1 import java.util.HashMap; ...

  6. 深入理解Java类型信息(Class对象)与反射机制

    关联文章: 深入理解Java类型信息(Class对象)与反射机制 深入理解Java枚举类型(enum) 深入理解Java注解类型(@Annotation) 深入理解Java并发之synchronize ...

  7. TF学习——TF之API:TensorFlow的高级机器学习API—tf.contrib.learn的简介、使用方法、案例应用之详细攻略

    TF学习--TF之API:TensorFlow的高级机器学习API-tf.contrib.learn的简介.使用方法.案例应用之详细攻略 目录 tf.contrib.learn的简介 tf.contr ...

  8. 使用扩展技术对SAP Fiori应用进行端到端的增强,一个实际案例介绍

    第一章 These series of blogs give a step-by-step instructions about how to extend SAP standard CRM Fior ...

  9. iOS夯实:内存管理

    最近的学习计划是将iOS的机制原理好好重新打磨学习一下,总结和加入自己的思考. 有不正确的地方,多多指正. 基本信息 Objective-C 提供了两种内存管理方式. MRR (manual reta ...

最新文章

  1. mysql split 按 分割_mysql分割字符串split
  2. SAP 电商云 Spartacus 产品明细页面的 canActivate 执行逻辑 - isUrlProtected
  3. Java从零基础到精通教程全套视频课程
  4. 用java编写的一个迪杰斯特拉算法(单源最短路径算法,Dijkstra算法)。
  5. 长串英文数字强制折行解决办法css
  6. MobileNets: Efficient Convolutional Neural Networks for Mobile Vision Applications
  7. 安卓开发之刮刮乐实例教程
  8. piggy back是什么意思?
  9. ubuntu16.04 独立显卡驱动安装
  10. js使用在指定数据前面或后面插入数据,对List数据排序
  11. Encoded password does not look like BCrypt 使用SpringSecurity中BCryptPasswordEncoder做盐值加密时出现错误
  12. 国产ETL工具/ETL 产品 (BeeDI ) 集团财务 双向同步 审核平台
  13. 微信小程序——云开发的安全规则
  14. 基于Java的商城购物系统
  15. ERP编制物料清单 金蝶
  16. 交叉编译-16:live555交叉编译(Windows和君正平台)
  17. 程序员 神经衰弱 植物神经紊乱 神经官能症 惊恐障碍 惊恐发作 焦虑症
  18. 电脑打开telnet功能
  19. java调用tshark_libtshark-core
  20. PHPOO知识点总结

热门文章

  1. 优化系统服务提升Win7系统运行速度
  2. 输入框限制输入为两位小数
  3. 【数据挖掘】二手汽车交易预测
  4. 第一届中国人工智能技术与应用大会在京召开
  5. kubernetes系列—PV和PVC详解
  6. Partial and Asymmetric Contrastive Learning for Out-of-Distribution Detection in Long-Tailed Recogni
  7. 1366 Incorrect string value: ‘\xE6\x9C\xB1\xE8\x8C\xB5‘ for column ‘NAME‘ at row 1
  8. [转载]日语基础语法(完整篇)
  9. 分带在中央经线在arcgis中的一些表示
  10. Extreme Programming (XP)实践