Does a value type keep Type pointer + Sync root + Static fields like a reference type? This question is an extended version of the following one: do-value-types-have-type-objects. Can anyone clarify:
- Do value types have a related System.Type-object stored in CLR heap?
- Where value type static fields and methods are stored if there is no associated type object?
- Do value types have sync root field (are value types thread safe if there is no sync
rootblock for them)?
No, There isn't. Structs don't have header associated with it and no type information is stored along with it. If you ask about the
System.Type
, yes the Type metadata will be in heap. But it won't be created upfront.Irrespective of ValueType or ReferenceType, static fields are stored in special heap called "High Frequency Heap" which you have one per AppDomain. Unlike the "Garbage Collected Heap", this heap is not garbage collected.
Above quote by Jon Skeet
Not sure what you're asking here. If you mean SyncBlock instead of Sync-Root, it has nothing to do with thread safety.