Introduce a callback API to have notifications when runtime resources exceed preset...
[mono.git] / mono / metadata / sgen-major-copy-object.h
index fe1cd6bf5120b6ad3a86db8642ae89916d01d220..7ed69b5ba48f48245aeb84f17f0cd75ee84aece6 100644 (file)
@@ -91,7 +91,13 @@ copy_object_no_checks (void *obj, SgenGrayQueue *queue)
        char *destination = major_alloc_object (objsize, has_references);
 
        if (G_UNLIKELY (!destination)) {
-               mono_sgen_pin_object (obj, queue);
+               if (ptr_in_nursery (obj)) {
+                       mono_sgen_pin_object (obj, queue);
+               } else {
+                       g_assert (objsize <= SGEN_MAX_SMALL_OBJ_SIZE);
+                       pin_major_object (obj, queue);
+               }
+               mono_sgen_set_pinned_from_failed_allocation (objsize);
                return obj;
        }