ICorProfilerCallback::MovedReferences Method
Called to report the new layout of objects in the heap as a result of a compacting garbage collection.
HRESULT MovedReferences(
[in] ULONG cMovedObjectIDRanges,
[in, size_is(cMovedObjectIDRanges)] ObjectID oldObjectIDRangeStart[] ,
[in, size_is(cMovedObjectIDRanges)] ObjectID newObjectIDRangeStart[] ,
[in, size_is(cMovedObjectIDRanges)] ULONG cObjectIDRangeLength[] );
Important
|
|---|
|
This method reports sizes as MAX_ULONG for objects that are greater than 4 GB on 64-bit platforms. To get the size of objects that are larger than 4 GB, use the ICorProfilerCallback4::MovedReferences2 method instead. |
A compacting garbage collector reclaims the memory occupied by dead objects and compacts that freed space. As a result, live objects might be moved within the heap, and ObjectID values distributed by previous notifications might change.
Assume that an existing ObjectID value (oldObjectID) lies within the following range:
oldObjectIDRangeStart[i] <= oldObjectID < oldObjectIDRangeStart[i] + cObjectIDRangeLength[i]
In this case, the offset from the start of the range to the start of the object is as follows:
oldObjectID - oldObjectRangeStart[i]
For any value of i that is in the following range:
0 <= i < cMovedObjectIDRanges
you can calculate the new ObjectID as follows:
newObjectID = newObjectIDRangeStart[i] + (oldObjectID – oldObjectIDRangeStart[i])
None of the ObjectID values passed by MovedReferences are valid during the callback itself, because the garbage collection might be in the middle of moving objects from old locations to new locations. Therefore, profilers should not attempt to inspect objects during a MovedReferences call. A ICorProfilerCallback2::GarbageCollectionFinished callback indicates that all objects have been moved to their new locations and inspection can be performed.
For more information about how the profiling API tracks ObjectID values, see Object Tracking in the Profiling API.
Platforms: See .NET Framework System Requirements.
Header: CorProf.idl, CorProf.h
Library: CorGuids.lib
.NET Framework Versions: 4.5, 4, 3.5 SP1, 3.5, 3.0 SP1, 3.0, 2.0 SP1, 2.0
Important