static int last_major_gc_warned = -1;
static int num_degraded = 0;
- if (last_major_gc_warned < gc_stats.major_gc_count) {
+ if (last_major_gc_warned < (int)gc_stats.major_gc_count) {
++num_degraded;
if (num_degraded == 1 || num_degraded == 3)
mono_trace (G_LOG_LEVEL_INFO, MONO_TRACE_GC, "Warning: Degraded allocation. Consider increasing nursery-size if the warning persists.");
if (!for_mature) {
sgen_client_degraded_allocation (size);
SGEN_ATOMIC_ADD_P (degraded_mode, size);
- sgen_ensure_free_space (size);
+ sgen_ensure_free_space (size, GENERATION_OLD);
} else {
if (sgen_need_major_collection (size))
sgen_perform_collection (size, GENERATION_OLD, "mature allocation failure", !for_mature);
* always loop we will loop endlessly in the case of
* OOM).
*/
- sgen_ensure_free_space (real_size);
+ sgen_ensure_free_space (real_size, GENERATION_NURSERY);
if (!degraded_mode)
p = (void **)sgen_nursery_alloc (size);
}
p = (void **)sgen_nursery_alloc_range (tlab_size, size, &alloc_size);
if (!p) {
/* See comment above in similar case. */
- sgen_ensure_free_space (tlab_size);
+ sgen_ensure_free_space (tlab_size, GENERATION_NURSERY);
if (!degraded_mode)
p = (void **)sgen_nursery_alloc_range (tlab_size, size, &alloc_size);
}
* LOCKING: The GC lock MUST be held.
*/
void
-sgen_ensure_free_space (size_t size)
+sgen_ensure_free_space (size_t size, int generation)
{
int generation_to_collect = -1;
const char *reason = NULL;
- if (size > SGEN_MAX_SMALL_OBJ_SIZE) {
+ if (generation == GENERATION_OLD) {
if (sgen_need_major_collection (size)) {
reason = "LOS overflow";
generation_to_collect = GENERATION_OLD;
void sgen_pin_object (GCObject *object, SgenGrayQueue *queue);
void sgen_set_pinned_from_failed_allocation (mword objsize);
-void sgen_ensure_free_space (size_t size);
+void sgen_ensure_free_space (size_t size, int generation);
void sgen_gc_collect (int generation);
void sgen_perform_collection (size_t requested_size, int generation_to_collect, const char *reason, gboolean wait_to_finish);
los_segment_index += size + sizeof (LOSObject);
g_assert (los_segment_index <= LOS_SEGMENT_SIZE);
#else
- sgen_ensure_free_space (size);
+ sgen_ensure_free_space (size, GENERATION_OLD);
#ifdef USE_MALLOC
obj = malloc (size + sizeof (LOSObject));