MSDN Today
I am speaking at the Chennai MSDN event today. The topic is "Inside the guts of the CLR".

Jonathan Stroud: Ptolemy's Gate (The Bartimaeus Trilogy, Book 3)
Jonathan Stroud: The Golem's Eye (The Bartimaeus Trilogy, Book 2)
Jonathan Stroud: The Amulet of Samarkand (The Bartimaeus Trilogy, Book 1)
« Refactoring out of VB 2005 | Main | CNUG Students in the News »
I am speaking at the Chennai MSDN event today. The topic is "Inside the guts of the CLR".
TrackBack URL for this entry:
http://www.typepad.com/services/trackback/6a00d83451a61969e200d83421f95853ef
Listed below are links to weblogs that reference MSDN Today:
» Inside the Guts of CLR!!! from Rays of Thoughts
Inside the Guts of CLR!!! [Read More]
You can follow this conversation by subscribing to the comment feed for this post.
This is only a preview. Your comment has not yet been posted.
As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.
Having trouble reading this image? View an alternate.
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | 4 | 5 | 6 | |
| 7 | 8 | 9 | 10 | 11 | 12 | 13 |
| 14 | 15 | 16 | 17 | 18 | 19 | 20 |
| 21 | 22 | 23 | 24 | 25 | 26 | 27 |
| 28 | 29 | 30 |
thanks for providing us wonderful/useful session..
before attending the session , i have a mindset, ... GC is doing its job, why i should know about it...Now i know the reasons why i should bother about it...
expectig more on whidbey stuff.
thanks again
Posted by: jaya | November 03, 2004 at 08:11 AM
Hello Mr. Anand,
The Presentation on "Inside CLR" was more informative and interesting. Especially the demonstration of "CLR Profiler" was very nice. Just now I'm downloading the same for testing my codes. Your presentations helps me to clearly understand about .Net's GC. Thank you so much for your great efforts.
What I need to do, to know the same kind of Tech. sessions in future?
Thanks and Regards,
Marimuthu K
Posted by: K.Marimuthu | November 03, 2004 at 02:00 PM
Marimuthu - if you've given your email id at the event, you would be mailed
Posted by: Sriram | November 04, 2004 at 07:52 AM
Dear Sir,
Let me summarise the session presented by you on 3rd Nov,at Le Meridien. And pls correct me if i understood anything wrong...
Subjects Discussed
1. CLR Host
2. GC
- Why .Net GC is best
- Memory Allocation basics
- GC Reference Tracing
- The collection Process
- Object Generations
- Finalize & why it is not preferable
- Comparison between string and StringBuilder
3. Strong and Weak reference
4. Whidbe CLR
- Edit and Continue technique (EnC)
- Generics
1. CLR Host
~~~~~~~~~~~
The different ways of hosting CLR into memory (implementation is a rare case, but for understanding CLR)
The CLR hosts are
a. Windows Shell
b. IIS
c. IE
4. * but, how to host the CLR programmatically?
As we think MSCOREE is not a CLR, it is a COM component to host the appropriate CLR on memory that’s all.
There are two important Methods inside the MSCOREE that are responsible to host the CLR
- CoreBindToRunTimeEX
- ICorRuntimeHost
Using the above two methods, we can programmatically host the CLR. demonstrated the same using VC++.Net code)
2. GC (the whole summary)
~~~~~~~~~~~~~~~~~~~~~~~~~
Deallocation of memory whenever the need of it to allocate for the new object.
How .Net GC performs well than any other GC (like C++, Java)
The earlier memory allocation and dealocation algorithms are based on Linked list. So every time we need to traverse through the list to find the referred object location & do the same for find the optimum location to store the newly created object. So, it will be fragmented structure after few allocation & dealocation process. It leads performance degrades.
But in .Net, we use optimized heap. So, whenever we create the object on memory assign it reference in the heap's top reference point. And every time GC executes it will reallocate the objects and assign the new reference in the heap. So the heap is always compact and optimized (expect the Large Object).
.Net GC using "Mark & Sweep" algorithm, whenever GC runs the rest of the objects in the memory will be marked as reachable object & it will be seeped from memory if it is orphan (object without handle in the root / heap).
Moreover, .Net GC classifies the object into three generations (0- younger, 1-middle, 2-older). every time the GC acts on 0th generation i.e. on the younger objects. If the Oth Generation object is still needed then GC marked it as 1st
generation as the same for 3rd. whenever theirs is a need of memory even after sweeping the first generation object then only
it will act on 2nd generation. And very rare it act on 3rd generation.
Here also, dealocation process is a very complex one. Because, it involves the following steps
1. Marking all Objects
2. Tracing the objects to find its reachability
3. swap the orphan objects
4. Relocate the object into the new location
5. change the reference pointer in the heap
So that only .Net tries to reduce calling GC often and give less preference for Destructors.
Finalize, is the method to manually free the object from memory. It may force the .Net to execute GC. So that only we should
try to avoid using finalize method. Even though we are using the finalize method, .Net will execute the GC only it is needed.
Using StringBuilder
~~~~~~~~~~~~~~~~~~~
He demonstrate by execute and comparing the performance between the code using "string" while other use the StringBuilder. Waw, great. when "string" program is executed, GC is runs 301 times where as only seven(7) for StringBuilder.
There is a tool called "CLR Profiler", which is used to see the performance chart. It is freely available in Microsoft website. I download and checking my programs.
You can download the same from
http://www.microsoft.com/downloads/details.aspx?FamilyId=86CE6052-D7F4-4AEB-9B7A-94635BEEBDDA&displaylang=en
3. Strong & Weak References
~~~~~~~~~~~~~~~~~~~~~~~~~~~
I'm not clear on this, so let me just give the short notes on it.
Strong reference : An object which can't be marked as orphan (unreachable) is known as strong referenced object.
Weak reference : even though it has the reference, may not be sure whether it is alive or not.
Weak references are two types
1. Short Weak reference
2. Long Week reference
4. Whidbey CLR
~~~~~~~~~~~~~
In the Visual Studio 2005, next release from Microsoft code named as "Whidbey" comes with the enhanced features such
like Edit and Continue (EnC), Generics etc.,
Edit and Continue (EnC)
~~~~~~~~~~~~~~~~~~~~~~~
In the current version of VS, we don't have the feature to edit the source code while it is executing. But from the next release programmer can enjoy by editing the code while executing the code parallel. The edited code will reflects in the next cycle. There are certain things can be allowed and some operations are still not allowed in EnC. They are...
Allowed:
~~~~~~~
1. Add private fields to a class
2. Add private non-virtual methods to a class
3. Change the function body (not its signature)
Disallowed:
~~~~~~~~~~~
1. Removing fields / methods
2. Editing generic classes
Generics
~~~~~~~
Same like templates available in C++. It will boost the performance by avoiding boxing and Unboxing process.
With Regards,
Marimuthu K
Posted by: Marimuthu | November 04, 2004 at 12:51 PM
Weak references let you hold references to objects without the danger of your holding a reference blocking the GC of that object. Let's say you're writing Win XP pic viewer and you want to write the 'prev' and 'next' buttons code.
Now consider that the user presses forward - you would lose the reference to the previous image and it would get GCed. But let's say the user presses back again - you'll now again have to fetch the image from disk though you had a reference to it seconds ago.
So you have a problem now - you dont want to hold images forever in memory - but you want to reuse images if they havent been GCed yet. This is what weak references give you - you hold a WeakReference to the object and you could *check* to see whether the image has been GCed. If it has, you have no choice but to load it from disk. But if it hasnt, you can just use the same pic from your RAM.
The key here is that you holding a WeakReference to this image wont prevent it from getting garbage collected
Posted by: Sriram | November 05, 2004 at 11:36 AM
Thank you Sriram,
I got it now.
Hope you are doing your course @ Anna University. Few months before I have attended a .Net session conducted by Chennai .Net Group, there I met one with the name Sriram. Are you the same Sriram?
Anyway thank you so much.
Posted by: Marimuthu | November 05, 2004 at 01:48 PM
Yup - that's me :-)
Posted by: Sriram | November 06, 2004 at 03:06 AM
And though my college comes under Anna Univ , I dont study at the Gunidy campus. I'm quite happy with SRM Engg College :-)
Posted by: Sriram Krishnan | November 06, 2004 at 03:07 AM