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.
相关问题
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Carriage Return (ASCII chr 13) is missing from tex
- Generic Generics in Managed C++
- Why am I getting UnauthorizedAccessException on th
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.
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