CLR Sync Block Address

When I do this:

public class Employee
{
    public int exp;
}

class Program
{
    static void Main(string[] args)
    {            
        Employee o1 = new Employee();
        o1.exp = 3;
        lock (o1)
        {
            //I am here
        }
    }
}

and get the memory o1 (address 0x022cf940):

enter image description here

I realized a couple of things mentioned below:

  • The green rectangle is a sync block that is 12
  • Blue rectangle - 4 byte type address
  • The red rectangle is 4 bytes, which is 3;

Question: Where is the space of synchronization blocks and how to find it? What does "12" mean?

+4
source share
1 answer

. Object.GetHashCode(), -, GetHashCode() . . , , , . , , , GetHashCode, , . .

- , , . , , 0x12 = 18 - Thread.ManagedThreadId , . , - .

, "4- ". ( " " ). , Object.GetType() . - , . exp, - Int32, 3 .

+11

All Articles