GC.IsPinnedHeapObject(object obj)
Returns true if the obj is allocated on pinned object heap.
Caveat: we generally cannot know cheaply/precisely if object is pinned (thus this is not a IsPinnedObject), but we can tell if it resides in Pinned Object Heap.
===
There are obvious scenarios where this could be useful.
When trying to use pinned object heap in prototypes, it does not take long before you want to write code like:
if (GC.IsPinnedHeapObject(obj))
{
.. something simple that relies on obj not relocating ..
}
else
{
.. pinning by hand for compat or throw something, if this is unexpected...
}
or do something like:
Debug.Assert(GC.IsPinnedHeapObject(buffer), "buffer must be on pinned heap");
GC.IsPinnedHeapObject(object obj)Returns true if the obj is allocated on pinned object heap.
Caveat: we generally cannot know cheaply/precisely if object is pinned (thus this is not a
IsPinnedObject), but we can tell if it resides in Pinned Object Heap.===
There are obvious scenarios where this could be useful.
When trying to use pinned object heap in prototypes, it does not take long before you want to write code like:
or do something like: