diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp index 9ffb1de45c4488..cd859833330743 100644 --- a/src/coreclr/gc/gc.cpp +++ b/src/coreclr/gc/gc.cpp @@ -49318,8 +49318,18 @@ HRESULT GCHeap::Initialize() } else { +#ifdef MULTIPLE_HEAPS // If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit. gc_heap::regions_range = max((size_t)256 * 1024 * 1024 * 1024, (size_t)(2 * gc_heap::total_physical_mem)); +#else // MUTLIPLE_HEAPS +#if defined(TARGET_IOS) || defined(TARGET_TVOS) + // On iOS and tvOS only try to reserve 1/4 of physical memory + gc_heap::regions_range = (size_t)(gc_heap::total_physical_mem / 4); +#else // TARGET_IOS && TARGET_TVOS + // If no hard_limit is configured the reservation size is min of 1/2 GetVirtualMemoryLimit() or max of 256Gb or 2x physical limit. + gc_heap::regions_range = (size_t)(2 * gc_heap::total_physical_mem); +#endif // TARGET_IOS && TARGET_TVOS +#endif // MUTLIPLE_HEAPS } size_t virtual_mem_limit = GCToOSInterface::GetVirtualMemoryLimit(); gc_heap::regions_range = min(gc_heap::regions_range, virtual_mem_limit/2); diff --git a/src/coreclr/gc/gcpriv.h b/src/coreclr/gc/gcpriv.h index e825b51d4d30c9..6806305ed1de6a 100644 --- a/src/coreclr/gc/gcpriv.h +++ b/src/coreclr/gc/gcpriv.h @@ -140,11 +140,11 @@ inline void FATAL_GC_ERROR() // // This means any empty regions can be freely used for any generation. For // Server GC we will balance regions between heaps. -// For now disable regions for standalone GC and macOS builds +// For now disable regions for standalone GC and iOS and tvOS builds // For SunOS or illumos this is temporary, until we can add MAP_PRIVATE // to the mmap() calls in unix/gcenv.unix.cpp More details here: // https://github.com/dotnet/runtime/issues/104211 -#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__APPLE__) && !defined(__sun) +#if defined (HOST_64BIT) && !defined (BUILD_AS_STANDALONE) && !defined(__sun) #define USE_REGIONS #endif //HOST_64BIT && BUILD_AS_STANDALONE && !__APPLE__ diff --git a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs index 92e8f656f681af..a80ac4abd49930 100644 --- a/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs +++ b/src/tests/nativeaot/SmokeTests/HardwareIntrinsics/Program.cs @@ -22,7 +22,7 @@ static int Main() long lowerBound, upperBound; lowerBound = 1200 * 1024; // ~1.2 MB - upperBound = 1600 * 1024; // ~1.6 MB + upperBound = 1700 * 1024; // ~1.7 MB if (fileSize < lowerBound || fileSize > upperBound) {