1. 程式人生 > >深入解密.NET(GC垃圾回收)

深入解密.NET(GC垃圾回收)

clas 不包含 ace 枚舉 double 技術分享 heap system sin

值類型與引用類型

值類型(Value Type),值類型實例通常分配在線程的堆棧(stack)上,並且不包含任何指向實例數據的指針,因為變量本身就包含了其實例數據

C#的所有值類型均隱式派生自System.ValueType:

結構體:struct(直接派生於System.ValueType),用戶定義的結構體(派生於System.ValueType);

整 型:sbyte(System.SByte的別名),short(System.Int16),int(System.Int32),long (System.Int64),byte(System.Byte),ushort(System.UInt16),uint (System.UInt32),ulong(System.UInt64),char(System.Char);

浮點型:float(System.Single),double(System.Double); 用於財務計算的高精度decimal型:decimal(System.Decimal)。

bool型:bool(System.Boolean的別名);

枚舉:enum(派生於System.Enum);

可空類型、派生於System.Nullable<T>泛型結構體,T?實際上是System.Nullable<T>的別名。

引用類型

C#有以下一些引用類型:

數組(派生於System.Array)

類:class(派生於System.Object);

接口:interface;

委托:delegate(派生於System.Delegate)。

object(System.Object);

字符串:string(System.String)。

內存圖(stack、Heap):

托管堆是基於進程的。

技術分享

GC

深入解密.NET(GC垃圾回收)