Only variable z is marked as pinned. It is easy to see if you look at
generated IL using ildasm.

The pinned pointers will show up as interior pointers during the GC
scan. For interior pointers, the GC uses bricktable to find the object
that encapsulates the given memory location and then operates on that.
If you want to see it in the code, look for GC_CALL_INTERIOR flag and
what's done differently when it is set.

So to answer your question, when a field in the object is pinned the
whole object will be pinned. This will happen inside the GC through
interior pointers. There does not have to be pinned variable holding
reference to the object.

-Jan

This posting is provided "AS IS" with no warranties, and confers no
rights.

-----Original Message-----
From: Discussion of the Rotor Shared Source CLI implementation
[mailto:[EMAIL PROTECTED] On Behalf Of Archana
Sent: Tuesday, January 05, 1999 10:01 AM
To: [EMAIL PROTECTED]
Subject: [DOTNET-ROTOR] pinning and fixed blocks

Hi,
 this is regarding Pinning objects using fixed(..) {}
If we have a piece of code like
fixed (obj* z= & objx.field) {
...
}
How does rotor treat the variables z and obj,
does it mark both as pinned?
when it pins objx does it pin just the field or the entire object?

regards

Reply via email to