Skip to Content
Shared Source CLI Essentials
book

Shared Source CLI Essentials

by David Stutz, Geoff Shilling, Ted Neward
March 2003
Intermediate to advanced
384 pages
10h 55m
English
O'Reilly Media, Inc.
Content preview from Shared Source CLI Essentials

Structuring Metadata for Collection

We have already touched on object layout in other chapters, but we should now look at it again in more detail. All object instances begin with a pointer to their method table; as we have seen, the space allocated for this pointer is overloaded during garbage collection to contain two critical bit flags, one for marking the object as live and the other for marking the object as pinned. It is guaranteed that the normal activity of the execution engine will be suspended during a collection, leaving the collector free to monkey around with memory. Because of this, the garbage collector can get away with overlaying bit flags directly; the pointer itself will always contain zeros in the necessary locations because of the way that memory is laid out, and the execution engine will not try to redirect through the pointer during collection.

The MethodTable, as we saw in Chapter 5, contains more than just a table of method pointers. It is also a useful place to store additional information related to garbage collection that is per-type rather than per-instance. As an example of this kind of per-type information, a set of flag bits for MethodTable can be seen in Example 7-15.

Example 7-15. MethodTable flags include garbage collection information (defined in clr/src/vm/class.h)

 enum { enum_flag_Array = 0x10000, enum_flag_large_Object = 0x20000, enum_flag_ContainsPointers = 0x40000, enum_flag_ClassInited = 0x80000, enum_flag_HasFinalizer = 0x100000, enum_flag_Sparse ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

C# 5.0 Unleashed

C# 5.0 Unleashed

Bart De Smet

Publisher Resources

ISBN: 059600351XCatalog PageErrata