corrections to GC out-of-memory handling

This commit is contained in:
Matthew Flatt 2015-01-22 10:11:11 -07:00
parent cffb63be56
commit db40c2f4ce
2 changed files with 3 additions and 1 deletions

View File

@ -222,7 +222,7 @@ static void *alloc_cache_alloc_page(AllocCacheBlock *blockfree, size_t len, siz
/* attempt to allocate from OS */
size_t extra = (alignment ? (alignment + CACHE_SEED_PAGES * APAGE_SIZE) : 0);
r = os_alloc_pages(len + extra);
if(r == (void *)-1) { return NULL; }
if(!r) { return NULL; }
if (alignment) {
/* We allocated too large so we can choose the alignment. */

View File

@ -181,6 +181,8 @@ static void *os_alloc_pages(size_t len)
retval = vm_allocate(task_self, (vm_address_t*)&r, len, TRUE);
if(retval != KERN_SUCCESS) {
if (retval == KERN_NO_SPACE)
return NULL;
GCPRINT(GCOUTF, "Couldn't allocate memory: %s\n", mach_error_string(retval));
abort();
}