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. Azkaban工作流调度器

    Azkaban工作流调度器 在Hadoop领域常用的工作流调度系统 Oozie,Azkaban,Cascading,Hamake等等. 性能对比: 安装: 创建ssl配置 keytool -keyst ...

  2. IntelliJ IDEA2018.3 最新破解方法

    IntelliJ IDEA2018.3 最新破解方法 输入    http://idea.java.sx/   即可,亲测可用.如果资金允许还是希望大家能支持正版,尊重原创 ------------- ...

  3. JAVA 把小数分成整数和小数

    在进行进制转换的时候,我们需要把小数分为整数和小数两部分. 这里介绍两种方法. 第一种举个例子:1.23分为1 和 0.23 第二种:1.23 分为 1 和23 有时需要具体情况具体分析自己需要哪种类 ...

  4. python+selenium+xpath 爬取天眼查工商基本信息

    # -*- coding:utf-8 -*-# author: kevin# CreateTime: 2018/8/16# software-version: python 3.7 import ti ...

  5. 前端经典面试题之CSS实现三栏布局,左右宽度固定,中间宽度自适应

    前端常问的面试题,题目:假设高度一定,请写出三栏布局,左右宽度300px,中间自适应. 看到这里我希望你能停下来思考几分钟, 1分钟~2分钟~3分钟~4分钟~5分钟! 好了,那么你想出了几种答案呢? ...

  6. 常被问到的十个 Java 面试题

    在这篇文章中,我试图收录最有趣和最常见的问题.此外,我将为您提供正确的答案. 接下来,就让我们来看看这些问题. 1. 以满分十分来评估自己——你有多擅长 Java? 如果你并不完全确信你自己或是你对 ...

  7. oracle权限列表

    alter any cluster 修改任意簇的权限 alter any index 修改任意索引的权限 alter any role 修改任意角色的权限 alter any sequence 修改任 ...

  8. Linux中一个文件10行内容,如何输出5-8内容到屏幕

    题目是这样的,Linux中一个文件10行内容,如何输出5-8内容到屏幕首先我们模拟一下这样的环境: [root@localhost question]# pwd /root/question [roo ...

  9. flex布局-弹性布局

    弹性布局当前应用的非常广泛,特别是移动端,记得第一次用reactNative 写代码的时候是最开始真正接触Flex布局.1.首先最外层的容器需要指定为display:flex;由于flex的兼容版本还 ...

  10. python学习博客地址集合。。。

    python学习博客地址集合...   老师讲课博客目录 http://www.bootcdn.cn/bootstrap/  bootstrap cdn在线地址 http://www.cnblogs. ...