Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / February 2004

Tip: Looking for answers? Try searching our database.

Some question about CLR and managed applications

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sheila Jones - 20 Feb 2004 11:21 GMT
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).
Mohamoss - 20 Feb 2004 15:10 GMT
Hello Sheila
yes what you stated in your post is correct  so for eample you should
dispose unmanged resourses before termination of your program
Sheila Jones - 20 Feb 2004 15:56 GMT
Thank you!

> Hello Sheila
>  yes what you stated in your post is correct  so for eample you should
> dispose unmanged resourses before termination of your program
Dave - 20 Feb 2004 23:30 GMT
> Hello,
>
[quoted text clipped - 8 lines]
> 3. When an application domain terminates, any objects it created will
> continue to exist. The garbage collector is not automatically triggered.

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.

> 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).

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.
Sheila Jones - 21 Feb 2004 08:43 GMT
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?

> > Hello,
> >
[quoted text clipped - 26 lines]
> destroyed all those objects are destroyed along with it; this implies that
> their finalizers will run and release the unmanaged resources.
Conrad Zhang - 21 Feb 2004 09:24 GMT
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.

> Hello, thank you so much for your helpful reply. I have a couple of
> follow-on questions.
[quoted text clipped - 8 lines]
> 3. Is the CLR absolutely guaranteed to run any pending finalizers when an
> app domain terminates?
Dave - 21 Feb 2004 11:32 GMT
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.

> 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)?

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.

> 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?

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.

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

Yes.

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.