Hi there,
I was just wondering that when an object's finalized method is called,
garbage collector must have marked it as garbage and unreachable even
though i am accessing the Static Variables of the Class after finalized
method is called.
So the doubt is whether the object is really been deallocated and if
yes how can i still access the static variable of the Class, ya i know
Static variables are irrelevant to the instance of a class, they are
shared but they are also consuming some memory and has to be released,
so wats the story behind Static Variables, firstly how are they
allocated in the managed heap and secondly how and when they are
deallocated.
Looking forward to a reply
Thanks and Regards
Saurabh Garg
Manoj G [MVP] - 05 Apr 2005 16:27 GMT
Saurabh,
Do not see static members as something that are allocated or collected in a
special way, different from normal objects. You can very well make a static
member eligible for a collection by setting it to null (provided that there
are no other references to the same object). If left untouched, a static
member would last for the life of the appdomain in which it lies.
HTH,
Manoj G
[MVP , Visual Developer - Visual Basic ]
http://msmvps.com/manoj/
> Hi there,
>
[quoted text clipped - 15 lines]
> Thanks and Regards
> Saurabh Garg
Kikalo - 06 Apr 2005 07:53 GMT
The GC considers static reference types to be roots.
Cumps,
RM
> Hi there,
>
[quoted text clipped - 15 lines]
> Thanks and Regards
> Saurabh Garg
Willy Denoyette [MVP] - 06 Apr 2005 22:28 GMT
> Hi there,
>
[quoted text clipped - 15 lines]
> Thanks and Regards
> Saurabh Garg
Static variables aren't released, the objects they are pointing at will
become eligible for GC when set to null (Nothing in VB). The static fields
themself are dropped when the AD unloads.
Willy.