public static void ProcessFinalizers() { while (true) { // Wait until there's some work to be done. If true is returned we should finalize objects, // otherwise memory is low and we should initiate a collection. if (InternalCalls.RhpWaitForFinalizerRequest() != 0) { if (s_fHaveNewClasslibs) { s_fHaveNewClasslibs = false; MakeFinalizerInitCallbacks(); } DrainQueue(); // Tell anybody that's interested that the finalization pass is complete (there is a race condition here // where we might immediately signal a new request as complete, but this is acceptable). InternalCalls.RhpSignalFinalizationComplete(); } else { // RhpWaitForFinalizerRequest() returned false and indicated that memory is low. We help // out by initiating a garbage collection and then go back to waiting for another request. InternalCalls.RhCollect(-1, InternalGCCollectionMode.Blocking); } } }
internal static void TriggerGC() { #if FEATURE_GC_STRESS if (GCStress.Initialized) { InternalCalls.RhCollect(-1, InternalGCCollectionMode.Blocking); } #endif }
public static void ProcessFinalizers() { while (true) { // Wait until there's some work to be done. If true is returned we should finalize objects, // otherwise memory is low and we should initiate a collection. if (InternalCalls.RhpWaitForFinalizerRequest() != 0) { if (s_fHaveNewClasslibs) { s_fHaveNewClasslibs = false; MakeFinalizerInitCallbacks(); } // Drain the queue of finalizable objects. Object target = InternalCalls.RhpGetNextFinalizableObject(); while (target != null) { // Call the finalizer on the current target object. If the finalizer throws we'll fail // fast via normal Redhawk exception semantics (since we don't attempt to catch // anything). unsafe { CalliIntrinsics.CallVoid(target.EEType->FinalizerCode, target); } target = InternalCalls.RhpGetNextFinalizableObject(); } // Tell anybody that's interested that the finalization pass is complete (there is a race condition here // where we might immediately signal a new request as complete, but this is acceptable). InternalCalls.RhpSignalFinalizationComplete(); } else { // RhpWaitForFinalizerRequest() returned false and indicated that memory is low. We help // out by initiating a garbage collection and then go back to waiting for another request. InternalCalls.RhCollect(-1, InternalGCCollectionMode.Blocking); } } }