Reputation: 31
It is written in link http://msdn.microsoft.com/en-us/magazine/bb985010.aspx
"When an application creates a new object, the new operator allocates the memory from the heap. If the object's type contains a Finalize method, then a pointer to the object is placed on the finalization queue."
Can someone please clarify me
1) It means, only when we explicitly use finalize (using destructor) then object will go to finalize queue.
2) Every .NET class by implicitly using finalize (using destructor) so all .net class library object will go to finalize queue.
3)what about our custom class like classs A { } class A obj will go to finalize or not ,cosidering both cases (explicit/implicit destructor )
4) If above class is written in unmanaged code what will happen.It will go to finalize queue or not
Thanks
Upvotes: 2
Views: 537
Reputation: 13238
1) Yes, objects which implement the Finalize()-method (the 'destructor' in C#) are added the the finalize-queue.
2) No, most of the .NET classes don't have Finalizer. When you don't implement one in your class, instances of that class won't be added to the finalize queue.
3) You class A will only go to the finalize-queue when it implements as Finalize-Method. (The 'destructor' in C#
4) Unmanaged class are not managed. The won't be garbage-collected nor added to the finalize-queue.
Some general notes.
Upvotes: 3