在.net implementaion垃圾收集,对象的行为是未知的,无法理解他们的行为 [英] Garbage Collection in .Net implementaion, objects behavior is unknown, unable to understand their behavior

查看:152
本文介绍了在.net implementaion垃圾收集,对象的行为是未知的,无法理解他们的行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做的.NET库的一些研究工作和conufsed有关行为,我尝试codeD在C#中的对象并检查他们。
我只是想知道,该对象是符合垃圾收集,当任何code是无法访问他们?运行GC功能之前,我们可以参照对象的一些其他内存,意味着我们可以将它们存储在内存?而forexample如果我们实行对他们的终结,将它必须是它的终结将在过程中的某些时候叫什么?
我想清楚了我的观念,我试图用一些C#code做到这一点,但我并不清楚。

I am doing some Research work on .Net libraries and conufsed about the behavior as i try to coded the objects in c# and checked them. I just want to know, that the objects are eligible for garbage collection, when any code is unable to access them? and before running GC function, can our objects referenced to some other memory, means can we move them in memory? And forexample if we implement finalizers for them, will it be must that its finalizers will be called at some point during process? I want to clear my concepts, i tried to use some c# code to do it, but i am not clear.

推荐答案

运行时保持可达对象图。当气相色谱运行,并已确定的目标是一垃圾那就看到该对象具有Finalize方法,将调用该方法,reclamining存储器。所有这一切都敲定方法对象从终结队列中删除并投入F-可达队列。一个特殊的运行线程专用于处理该队列,并调用finalize每个对象的方法。

The runtime maintains a graph of reachable objects. When GC runs and has determined that an object is a garbage then it would see that object has a Finalize method and will call the method, reclamining memory. All the objects which have Finalize method are removed from finalization queue and put into F-Reachable queue. A special runtime thread is dedicated to process this queue and call finalize method of each object.

我建议你阅读下面的MSDN文章由杰弗里里氏。这是一个3部分组成的文章,并会清除所有的疑虑。

I suggest you read following article by Jeffery Richter at MSDN. It's a 3 part article and would clear all your doubts.

http://msdn.microsoft.com/en-us/magazine/ bb985010.aspx

这篇关于在.net implementaion垃圾收集,对象的行为是未知的,无法理解他们的行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆