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;
}