@@ -3212,7 +3212,7 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
3212
3212
uint64_t target_heap ;
3213
3213
const char * reason = "" ; (void )reason ; // for GC_TIME output stats
3214
3214
old_heap_size = heap_size ; // TODO: Update these values dynamically instead of just during the GC
3215
- if (collection == JL_GC_AUTO ) {
3215
+ if (collection == JL_GC_AUTO && jl_options . hard_heap_limit == UINT64_MAX ) {
3216
3216
// update any heuristics only when the user does not force the GC
3217
3217
// but still update the timings, since GC was run and reset, even if it was too early
3218
3218
uint64_t target_allocs = 0.0 ;
@@ -3301,21 +3301,12 @@ static int _jl_gc_collect(jl_ptls_t ptls, jl_gc_collection_t collection)
3301
3301
heap_size , jl_options .hard_heap_limit );
3302
3302
}
3303
3303
// Ignore heap limit computation from MemBalancer-like heuristics
3304
- // if the user has set a `--hard-heap-limit` through the command line.
3305
- // Note that if we reach this code, we can guarantee that the heap size
3306
- // is less than the hard limit, so there will be some room to grow the heap
3307
- // until the next GC without hitting the hard limit.
3308
- if (jl_options .hard_heap_limit != UINT64_MAX ) {
3309
- jl_atomic_store_relaxed (& gc_heap_stats .heap_target , jl_options .hard_heap_limit );
3310
- target_heap = jl_options .hard_heap_limit ;
3311
- }
3312
- // Ignore heap limit computation from MemBalancer-like heuristics
3313
3304
// if the heap target increment goes above the value specified through
3314
3305
// `--upper-bound-for-heap-target-increment`.
3315
3306
// Note that if we reach this code, we can guarantee that the heap size
3316
3307
// is less than the hard limit, so there will be some room to grow the heap
3317
3308
// until the next GC without hitting the hard limit.
3318
- if (target_heap - heap_size > jl_options .upper_bound_for_heap_target_increment ) {
3309
+ if (jl_options .upper_bound_for_heap_target_increment != UINT64_MAX ) {
3319
3310
target_heap = heap_size + jl_options .upper_bound_for_heap_target_increment ;
3320
3311
jl_atomic_store_relaxed (& gc_heap_stats .heap_target , target_heap );
3321
3312
}
@@ -3718,6 +3709,9 @@ void jl_gc_init(void)
3718
3709
arraylist_new (& finalizer_list_marked , 0 );
3719
3710
arraylist_new (& to_finalize , 0 );
3720
3711
jl_atomic_store_relaxed (& gc_heap_stats .heap_target , default_collect_interval );
3712
+ if (jl_options .hard_heap_limit != UINT64_MAX ) {
3713
+ jl_atomic_store_relaxed (& gc_heap_stats .heap_target , jl_options .hard_heap_limit );
3714
+ }
3721
3715
gc_num .interval = default_collect_interval ;
3722
3716
gc_num .allocd = 0 ;
3723
3717
gc_num .max_pause = 0 ;
0 commit comments