Life Cycle of Object

简介:   Garbage collection, managed heap.   Set object to null. Application root.

 

Garbage collection, managed heap.

 

Set object to null.

Application root.

Generation.

 

System.GC type

GC.Collect();

GC.WaitForPendingFinalizers();

 

 

class A

{

~A()

{

//clear unmanaged resources.

}

}

 

public interface IDisposable

{

void Dispose();

}

public class A:IDisposable

{

Private bool disposed=false;

public void Dispose()

{

//clear unmanaged resources.

}

private void CleanUp(bool disposing)

{

If(!this.disposed)

{

if(disposing)

{

//free managed resources.

}

}

disposed=true;

}

~A()

{

//clear unmanaged resources.

CleanUp(false);

}

 

}

 

Using(A a=new A())

{

//automatically call Dispose() when exit.

}

目录
打赏
0
0
0
0
20
分享
相关文章
Document-Level event Extraction via human-like reading process 论文解读
文档级事件抽取(DEE)特别困难,因为它提出了两个挑战:论元分散和多事件。第一个挑战意味着一个事件记录的论元可能存在于文档中的不同句子中
113 0
YOLOv7: Trainable bag-of-freebies sets new state-of-the-art for real-time object detectors
YOLOv7在5 FPS到160 FPS的范围内,在速度和精度方面都超过了所有已知的物体检测器,在GPU V100上以30 FPS或更高的速度在所有已知的实时物体检测器中具有最高的精度56.8% AP。
509 0
RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel
RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel
129 0
【1106】Lowest Price in Supply Chain (25 分)
【1106】Lowest Price in Supply Chain (25 分) 【1106】Lowest Price in Supply Chain (25 分)
105 0
Speed Matters: How To Process Big Data Securely For Real-time Applications
Big Data processing has stepped up to provide organizations with new tools and technologies to improve business efficiency and competitive advantage.
1327 0
Speed Matters: How To Process Big Data Securely For Real-time Applications
AI助理

你好,我是AI助理

可以解答问题、推荐解决方案等