Example #1
0
/* size is a multiple of SGEN_ALLOC_ALIGN */
static void*
major_alloc_small_pinned_obj (size_t size, gboolean has_references)
{
	void *res;

	ms_wait_for_sweep_done ();

	res = alloc_obj (size, TRUE, has_references);
	 /*If we failed to alloc memory, we better try releasing memory
	  *as pinned alloc is requested by the runtime.
	  */
	 if (!res) {
		 sgen_collect_major_no_lock ("pinned alloc failure");
		 res = alloc_obj (size, TRUE, has_references);
	 }
	 return res;
}
Example #2
0
static void*
alloc_degraded (MonoVTable *vtable, size_t size, gboolean for_mature)
{
	static int last_major_gc_warned = -1;
	static int num_degraded = 0;

	if (!for_mature) {
		if (last_major_gc_warned < stat_major_gcs) {
			++num_degraded;
			if (num_degraded == 1 || num_degraded == 3)
				fprintf (stderr, "Warning: Degraded allocation.  Consider increasing nursery-size if the warning persists.\n");
			else if (num_degraded == 10)
				fprintf (stderr, "Warning: Repeated degraded allocation.  Consider increasing nursery-size.\n");
			last_major_gc_warned = stat_major_gcs;
		}
	}

	if (mono_sgen_need_major_collection (0)) {
		sgen_collect_major_no_lock ("degraded overflow");
	}

	return major_collector.alloc_degraded (vtable, size);
}