.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 ...
随机推荐
- vscode 中 eslint 相关配置
1.设置vue等文件有eslint提示 "eslint.validate": [ "javascript", "javascriptreact&quo ...
- 2017年11月23日**科技面试java工程师面试总结
从整个面试看了,表现并不理想,有很多不足. 1.关于手机页面闪现问题的处理.从原理上观察,页面闪现是因为异步请求导致的.在进入页面中首先会加载默认的东西,此时也会访问数据库端,会用ajax判断是否满足 ...
- EasyUI 中 Combobox里的onChange和onSelect事件的区别
EasyUI 中 Combobox 选项发生改变时会触发 onChange,onSelect,onClick 3 个事件. 最近要做一个级联的 Combo 菜单,类似于选择地址时让用户填写省,市,区的 ...
- 使用有序GUID:提升其在各数据库中作为主键时的性能
原文出处:https://www.codeproject.com/articles/388157/guids-as-fast-primary-keys-under-multiple-database ...
- lumion实例渲染6.2
放置一些树 打开室外材质库,选择一个·别墅 放车 “景观”“描绘系统”笔刷调大刷出地面, 人群安置一些墙 改变方向,增大数量,墙就连在一起, 放一些树篱在墙上. 拍照模式添加特效,太阳 添加特效,天气 ...
- Vue.js学习过程
打开各大论坛,看到好多Vue.js的话题,可以说现在是非常火的框架,看到一个人这样评论Vue:“Vue.js兼容angular.js和 react.js的优点,并剔除他们的缺点.”因为现在公司不用Vu ...
- 无服务器架构(Faas/Serverless)
摘要无服务器架构(Faas/Serverless),是软件架构领域的热门话题. AWS,Google Cloud和Azure - 在无服务器上投入了大量资金,已经在看到了大量专门针对Faas/Serv ...
- 一款堪称完美的编程字体Source Code Pro
对于程序员来说,好的字体应该满足的基本条件: 字母和数字易于分辨,如: 英文字母o 和 阿拉伯数字 0 ,或者 英文字母 l 和 阿拉伯数字 1 ,两个单引号 '' 和双引号 ”. 字体等宽,保持对齐 ...
- Unity3d KeyCode 键盘各种键值详情
KeyCode :KeyCode是由Event.keyCode返回的.这些直接映射到键盘上的物理键. 值 对应键 Backspace 退格键 Delete Delete ...
- Java利用cors实现跨域请求
由于ajax本身实际上是通过XMLHttpRequest对象来进行数据的交互,而浏览器出于安全考虑,不允许js代码进行跨域操作,所以会警告 网站开发,在某些情况下需要用到跨域. 什么是跨域? 跨域,指 ...