@@ -681,16 +681,16 @@ static int64_t last_gc_total_bytes = 0;
681681// max_total_memory is a suggestion. We try very hard to stay
682682// under this limit, but we will go above it rather than halting.
683683#ifdef _P64
684- typedef uint64_t memsize_t ;
685- static const size_t default_collect_interval = 5600 * 1024 * sizeof (void * );
686- static const size_t max_collect_interval = 1250000000UL ;
687- static size_t total_mem ;
684+ typedef int64_t memsize_t ;
685+ static const int64_t default_collect_interval = 5600 * 1024 * sizeof (void * );
686+ static const int64_t max_collect_interval = 1250000000UL ;
687+ static int64_t total_mem ;
688688// We expose this to the user/ci as jl_gc_set_max_memory
689689static memsize_t max_total_memory = (memsize_t ) 2 * 1024 * 1024 * 1024 * 1024 * 1024 ;
690690#else
691- typedef uint32_t memsize_t ;
692- static const size_t default_collect_interval = 3200 * 1024 * sizeof (void * );
693- static const size_t max_collect_interval = 500000000UL ;
691+ typedef int32_t memsize_t ;
692+ static const int32_t default_collect_interval = 3200 * 1024 * sizeof (void * );
693+ static const int32_t max_collect_interval = 500000000UL ;
694694// Work really hard to stay within 2GB
695695// Alternative is to risk running out of address space
696696// on 32 bit architectures.
@@ -3948,13 +3948,17 @@ void jl_gc_init(void)
39483948
39493949JL_DLLEXPORT void jl_gc_set_max_memory (uint64_t max_mem )
39503950{
3951- if (max_mem > 0
3952- && max_mem < (uint64_t )1 << (sizeof (memsize_t ) * 8 - 1 )) {
3951+ #ifdef _P64
3952+ const int64_t max_allowed_value = INT64_MAX ;
3953+ #else
3954+ const int32_t max_allowed_value = INT32_MAX ;
3955+ #endif
3956+ if (max_mem > 0 && max_mem < max_allowed_value ) {
39533957 max_total_memory = max_mem ;
39543958 }
39553959}
39563960
3957- JL_DLLEXPORT uint64_t jl_gc_get_max_memory (void )
3961+ JL_DLLEXPORT int64_t jl_gc_get_max_memory (void )
39583962{
39593963 return max_total_memory ;
39603964}
0 commit comments