all groups > dotnet clr > february 2004 >
You're in the

dotnet clr

group:

Some question about CLR and managed applications


Some question about CLR and managed applications Sheila Jones
2/20/2004 11:21:47 AM
dotnet clr:
Hello,

I'm trying to get my brain around the CLR! Can somebody tell me if the
following are correct? Thanks.

1. The CLR runs each managed application in its own application domain, but
there can be several application domains within the same process.

2. The managed heap is shared by all application domains within the process.

3. When an application domain terminates, any objects it created will
continue to exist. The garbage collector is not automatically triggered.

4. Consequently, an application with objects that wrap unmanaged resources
should dispose of them before terminating, because termination won't
immediately release the resources (unlike with unmanaged applications).

RE: Some question about CLR and managed applications mohamed.mossad NO[at]SPAM egdsc.microsoft.com
2/20/2004 3:10:05 PM
Hello Sheila
yes what you stated in your post is correct so for eample you should
dispose unmanged resourses before termination of your program
Re: Some question about CLR and managed applications Sheila Jones
2/20/2004 3:56:33 PM
Thank you!


[quoted text, click to view]

Re: Some question about CLR and managed applications Dave
2/20/2004 5:30:03 PM

[quoted text, click to view]

Not true. Objects that are created in that appdomain are destroyed along
with that appdomain. First all unreachable objects are reclaimed, then
objects that are still rooted but belong to that appdomain are finalized.
The GC runs through several cycles when an appdomain is destroyed.

[quoted text, click to view]
This is complicated. Generally speaking you want managed objects that wrap
unmanaged to implement both a finalizer and a Dispose pattern. Normally you
should use the Dispose method and use the finalizer as a backstop. If you
create an object in the context of an appdomain then when the appdomain is
destroyed all those objects are destroyed along with it; this implies that
their finalizers will run and release the unmanaged resources.

Re: Some question about CLR and managed applications Conrad Zhang
2/21/2004 1:24:30 AM
1. There is only one garbage collector.
2. You can search MSDN for Garbage collector articles. Basically it collects
everything.
3. Yes and No. Please read
http://weblogs.asp.net/cbrumme/archive/2004/02/20/77460.aspx for more on
finalization.

[quoted text, click to view]

Re: Some question about CLR and managed applications Dave
2/21/2004 5:32:38 AM
The link that Conrad provided has a lot of good information. Brumme is "the"
word on internals. I added a brief note by some of your questions.


[quoted text, click to view]
heap)?

Currently one but this may change. There's talk about adding more
finalization threads, more GC, etc. However, from an app's perspective you
should not need to worry about the implementation details.

[quoted text, click to view]
It guarantees that at a minimum objects from the doomed appdomain are
collected; more then that is not defined by there's nothing that would
prevent it.

[quoted text, click to view]
Yes.

Re: Some question about CLR and managed applications Sheila Jones
2/21/2004 8:43:30 AM
Hello, thank you so much for your helpful reply. I have a couple of
follow-on questions.

1. Does each application domain have its own garbage collector, or is there
just one for all app domains in the process (since there is just one heap)?

2. When the garbage collector is triggered by an app. domain terminating,
does it garbage collect the whole heap (including objects from any other app
domains), or just the objects from the terminating app domain?

3. Is the CLR absolutely guaranteed to run any pending finalizers when an
app domain terminates?


[quoted text, click to view]

AddThis Social Bookmark Button