gboolean
sgen_need_major_collection (mword space_needed)
{
- mword los_alloced = los_memory_usage - MIN (last_collection_los_memory_usage, los_memory_usage);
+ mword los_alloced;
+ if (sgen_concurrent_collection_in_progress ())
+ return FALSE;
+ los_alloced = los_memory_usage - MIN (last_collection_los_memory_usage, los_memory_usage);
return (space_needed > sgen_memgov_available_free_space ()) ||
minor_collection_sections_alloced * major_collector.section_size + los_alloced > minor_collection_allowance;
}
}
void
-sgen_assert_memory_alloc (void *ptr, const char *assert_description)
+sgen_assert_memory_alloc (void *ptr, size_t requested_size, const char *assert_description)
{
if (ptr || !assert_description)
return;
- fprintf (stderr, "Error: Garbage collector could not allocate memory for %s.\n", assert_description);
+ fprintf (stderr, "Error: Garbage collector could not allocate %zu bytes of memory for %s.\n", requested_size, assert_description);
exit (1);
}
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
ptr = mono_valloc (0, size, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
- sgen_assert_memory_alloc (ptr, assert_description);
+ sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
if (flags & SGEN_ALLOC_HEAP)
g_assert (!(flags & ~(SGEN_ALLOC_HEAP | SGEN_ALLOC_ACTIVATE)));
ptr = mono_valloc_aligned (size, alignment, prot_flags_for_activate (flags & SGEN_ALLOC_ACTIVATE));
- sgen_assert_memory_alloc (ptr, assert_description);
+ sgen_assert_memory_alloc (ptr, size, assert_description);
if (ptr) {
SGEN_ATOMIC_ADD_P (total_alloc, size);
if (flags & SGEN_ALLOC_HEAP)
return;
if (max_heap < soft_limit) {
- fprintf (stderr, "max-heap-size must be at least as large as soft-heap-limit.\n");
- exit (1);
+ sgen_env_var_error (MONO_GC_PARAMS_NAME, "Setting to minimum.", "`max-heap-size` must be at least as large as `soft-heap-limit`.");
+ max_heap = soft_limit;
}
if (max_heap < sgen_nursery_size * 4) {
- fprintf (stderr, "max-heap-size must be at least 4 times larger than nursery size.\n");
- exit (1);
+ sgen_env_var_error (MONO_GC_PARAMS_NAME, "Setting to minimum.", "`max-heap-size` must be at least 4 times as large as `nursery size`.");
+ max_heap = sgen_nursery_size * 4;
}
max_heap_size = max_heap - sgen_nursery_size;