Managed Heaps

In general it can be categorized into 1) SOH and 2) LOH.  size lower than 85K will be in SOH, size larger than 85K will be in LOH.

Small Object Heap

GC will do 1) Mark 2) Sweep 3) Compact on SOH.

How GC works

When a small object is created (less than 85KB in size), it is stored in the small object heap. The CLR organizes the small object heap into three generations – generation 0, generation 1, and generation 2 – that are collected at different intervals. Small objects are generally allocated to generation 0, and if they survive a GC cycle, they are promoted to generation 1. If they survive the next GC cycle, they are promoted to generation 2.

Further, garbage collection of the small object heap includes compaction, meaning that as unused objects are collected, the GC moves living objects into the gaps to eliminate fragmentation and make sure that the available memory is contiguous. Of course, compaction involves overhead – both CPU cycles and additional memory for copying objects. Because the benefits of compaction outweigh the costs for small objects, compaction is performed automatically on the small object heap.

GC uses generational garbition collection. .Net will device memory into 3 generations. Gen 0 is the youngest one, Gen 2 is the olddest one.

Gen 0 collection will empty Gen 0 for sure. Either move the objects to Gen 1, or Die and compact the rootless objects.

Gen 1 collection will scan gen 0 and gen 1 both, for objects still has root reference, move them from gen 0 to gen 1, and move the ones in gen 1 to gen 2.

Gen 2 is a full collection because all of the generations are inspected and colleted.

Gen 0, Gen 1 and Gen 2 are 10 times difference compared to each other.

Some object may have un-managed resources, so these objects will have their reference added to the Finalization Queue.  There is a seperate thread other than GC which will run and call Finalize () method to recycle the objects.

For rootless objects, collect them. in SOH, compact the available space.  in LOH, it does not do compaction, but it will maintain a free memory table.  next time, when there is a object > 85KB, it will check free table firstly, if it can accomodate the object, save it, if not, do fragmentation and allocate new memory.

.Net memory management Learning Notes的更多相关文章

  1. Operating System Memory Management、Page Fault Exception、Cache Replacement Strategy Learning、LRU Algorithm

    目录 . 引言 . 页表 . 结构化内存管理 . 物理内存的管理 . SLAB分配器 . 处理器高速缓存和TLB控制 . 内存管理的概念 . 内存覆盖与内存交换 . 内存连续分配管理方式 . 内存非连 ...

  2. Obj-C Memory Management

    Memory management is one of the most important process in any programming language. It is the proces ...

  3. Memory Management in Open Cascade

    Open Cascade中的内存管理 Memory Management in Open Cascade eryar@163.com 一.C++中的内存管理 Memory Management in ...

  4. Java (JVM) Memory Model – Memory Management in Java

    原文地址:http://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java Understanding JV ...

  5. Objective-C Memory Management

    Objective-C Memory Management Using Reference Counting 每一个从NSObject派生的对象都继承了对应的内存管理的行为.这些类的内部存在一个称为r ...

  6. Android内存管理(2)HUNTING YOUR LEAKS: MEMORY MANAGEMENT IN ANDROID PART 2

    from: http://www.raizlabs.com/dev/2014/04/hunting-your-leaks-memory-management-in-android-part-2-of- ...

  7. Android内存管理(1)WRANGLING DALVIK: MEMORY MANAGEMENT IN ANDROID PART 1

    from : http://www.raizlabs.com/dev/2014/03/wrangling-dalvik-memory-management-in-android-part-1-of-2 ...

  8. Understanding Memory Management(2)

    Understanding Memory Management Memory management is the process of allocating new objects and remov ...

  9. Java Memory Management(1)

    Java Memory Management, with its built-in garbage collection, is one of the language’s finest achiev ...

随机推荐

  1. day1扩展作业

    作业一:博客作业二:编写登陆接口,●输入用户名密码(有文件存储用户名,命名)●认证成功后显示欢迎信息●输错三次后锁定(再次运行程序,还是输入上次输入的就显示已被锁定)作业三:多级菜单●三级菜单 ●可依 ...

  2. angular学习笔记(2)

    1.angular可观察对象 2.angular绑定方式 3.angular模板 4.angular生命周期 5.angular组件通信

  3. RSA加密、解密、签名、验签的原理及方法

    一.RSA加密简介 RSA加密是一种非对称加密.可以在不直接传递密钥的情况下,完成解密.这能够确保信息的安全性,避免了直接传递密钥所造成的被破解的风险.是由一对密钥来进行加解密的过程,分别称为公钥和私 ...

  4. gitlab安装随记

    gitlab安装 配置yum源 sudo vim /etc/yum.repos.d/gitlab-ce.repo 按照网上别人的例子,修改为清华的源 [gitlab-ce] name=Gitlab C ...

  5. [BZOJ3167]Sao

    Problem 给你n个任务,n-1个关系,ab代表a在b前或者a在b后 问你有几种拓扑序 Solution f[i][j]表示第i个节点前有j个节点的方案数 设当前节点为x,儿子节点为s,若x依赖于 ...

  6. 关于Servlet的一些归纳(1)

    1.servlet接口 含5个抽象放法 void init(ServletConfig config) throws ServletException //初始化Servlet void servic ...

  7. 成功使Linux服务端和Windows客户端建立socket通信

    一.准备工作 1.一台装有虚拟机的Windows7操作系统,虚拟机中装的是CentOS6.5版本的Linux 2.Windows7已经装有java环境 二.编码 使用java编写socket通信的服务 ...

  8. 背景图片利用backgrond-posintion属性实现不同形式的分割

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  9. 基于vue项目的组件中导入mui框架初始化滑动等效果时需移除严格模式的问题

    基于vue项目的组件中导入mui框架初始化滑动等效果时,控制台报错:Uncaught TypeError: 'caller', 'callee', and 'arguments' properties ...

  10. JavaWeb笔记三、MVC 设计模式

    一.通过 MVC 进行查询和删除操作 1. 准备一个数据表(examstudent) 2. 创建一个 查询 页面(test.jsp) 通过连接进入 Servlet(listAllStudents.ja ...