HighTechTalks DotNet Forums  

Static member

Dotnet Framework (Performance) microsoft.public.dotnet.framework.performance


Discuss Static member in the Dotnet Framework (Performance) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Napo
 
Posts: n/a

Default Static member - 11-21-2005 , 02:44 AM






Hi:
I declare a dataset obejct as static type in one class, such as:
class A{
private static dataset ds;
public void process(){
// some code
}
}
I want to know if the ds object can be disposed by handly.
what does JIT do when it compile this class ?

Reply With Quote
  #2  
Old   
Manoj G [MVP]
 
Posts: n/a

Default Re: Static member - 11-21-2005 , 01:33 PM






Hi,

You can set the ds variable to null, thereby making the object referenced by
ds eligible for garbage collection (provided it has no other root
references, like another static member pointing to the same object).
Otherwise, lifetime of static members is that of the containing appdomain
itself, and are collected only when the appdomain is unloaded.
JIT compilation is a per method operation. Could you be more specific with
your question?

--
HTH,
Manoj G
MVP, Visual Developer
http://msmvps.com/manoj

"Napo" <Napo (AT) discussions (DOT) microsoft.com> wrote

Quote:
Hi:
I declare a dataset obejct as static type in one class, such as:
class A{
private static dataset ds;
public void process(){
// some code
}
}
I want to know if the ds object can be disposed by handly.
what does JIT do when it compile this class ?



Reply With Quote
  #3  
Old   
Napo
 
Posts: n/a

Default Re: Static member - 11-27-2005 , 09:43 PM



Thank you for your reply.
I think that the static dataset will never be disposed in this scenario
until I stop the application.
about JIT compilation , I want to know if the static object will be
associated tho appdomain when vs.net IDE compiled it.


"Manoj G [MVP]" wrote:

Quote:
Hi,

You can set the ds variable to null, thereby making the object referenced by
ds eligible for garbage collection (provided it has no other root
references, like another static member pointing to the same object).
Otherwise, lifetime of static members is that of the containing appdomain
itself, and are collected only when the appdomain is unloaded.
JIT compilation is a per method operation. Could you be more specific with
your question?

--
HTH,
Manoj G
MVP, Visual Developer
http://msmvps.com/manoj

"Napo" <Napo (AT) discussions (DOT) microsoft.com> wrote in message
news:3A062708-522D-4559-B57B-CB8569247492 (AT) microsoft (DOT) com...
Hi:
I declare a dataset obejct as static type in one class, such as:
class A{
private static dataset ds;
public void process(){
// some code
}
}
I want to know if the ds object can be disposed by handly.
what does JIT do when it compile this class ?




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.