.Net memory management Learning Notes
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的更多相关文章
- Operating System Memory Management、Page Fault Exception、Cache Replacement Strategy Learning、LRU Algorithm
目录 . 引言 . 页表 . 结构化内存管理 . 物理内存的管理 . SLAB分配器 . 处理器高速缓存和TLB控制 . 内存管理的概念 . 内存覆盖与内存交换 . 内存连续分配管理方式 . 内存非连 ...
- Obj-C Memory Management
Memory management is one of the most important process in any programming language. It is the proces ...
- Memory Management in Open Cascade
Open Cascade中的内存管理 Memory Management in Open Cascade eryar@163.com 一.C++中的内存管理 Memory Management in ...
- Java (JVM) Memory Model – Memory Management in Java
原文地址:http://www.journaldev.com/2856/java-jvm-memory-model-memory-management-in-java Understanding JV ...
- Objective-C Memory Management
Objective-C Memory Management Using Reference Counting 每一个从NSObject派生的对象都继承了对应的内存管理的行为.这些类的内部存在一个称为r ...
- 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- ...
- 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 ...
- Understanding Memory Management(2)
Understanding Memory Management Memory management is the process of allocating new objects and remov ...
- Java Memory Management(1)
Java Memory Management, with its built-in garbage collection, is one of the language’s finest achiev ...
随机推荐
- springcloud-zuul路由网关
路由网关(zuul) 在微服务架构中,需要多个基础的服务治理组件,包括服务注册与发现.服务消费.负载均衡.断路器.智能 路由.配置管理等,由这个基础组件相互协作,共同组建了一个简单的微服务系统.一个简 ...
- 将VMware虚拟机系统镜像导入到ESXi vSphere
原因: 公司有一个VMware虚拟机的交叉编译镜像,但主机性能不行,因此需要将镜像导入ESXi vSphere 过程: 1.将WMware虚拟机克隆; 2.将虚拟机的多个磁盘文件合并成一个;(否则vS ...
- Nmap UDP扫描缓慢问题探究(无结果)
一.说明 在网络原理中我们经常说TCP是面向连接的要进行三次握手和四次挥手所以速度比较慢,UDP是无连接的直接发送和接收所以速度快(说到这个快慢我总想起多年前有篇分析MSN为什么被QQ淘汰的一篇文章其 ...
- CentOS7系统上的LAPACK源码安装
参考链接:linux下安装blas和lapack BLAS 和 LAPACK 这两个数学库是很多 Linux 科学计算软件需要调用的,所以经常会用到. LAPACK,其名为Linear Algebra ...
- WebService调用SSAS教程
WebService调用SSAS教程 一.创建SSAS项目 使用SQL Server Business Intelligence Development Studio新建Analysis Servic ...
- Touch事件分发源码解析
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 以下源码基于Gingerbread 2.3.7 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1.先看ViewGroup的di ...
- 【js高程学习笔记】关于变量值和函数参数
变量包含了两种不同类型的值: 基本类型 (Undefined.null.Boolean.Number.string都属于基本类型) 引用类型 (对象) 两种值在赋值上不同的是: 将一个引用类型的值(对 ...
- 关于FFmpeg工具的使用总结
FFmpeg官网:http://ffmpeg.org/ 安装ffmpeg: http://www.cnblogs.com/freeweb/p/6897907.html 主要参数: -i 设定输入流 - ...
- SQL-54 查找排除当前最大、最小salary之后的员工的平均工资avg_salary。
题目描述 查找排除当前最大.最小salary之后的员工的平均工资avg_salary.CREATE TABLE `salaries` ( `emp_no` int(11) NOT NULL,`sala ...
- VMware Pro 14.1.2 官方正式版及激活密钥
热门虚拟机软件VMware Workstation Pro现已更新至14.1.2,14.0主要更新了诸多客户机操作系统版本,此外全面兼容Wind10创建者更新.12.0之后属于大型更新,专门为Win1 ...