diff --git a/src/gc.c b/src/gc.c index cb2bab9acd59f..19a1899f9e2d8 100644 --- a/src/gc.c +++ b/src/gc.c @@ -3864,7 +3864,8 @@ void jl_gc_init(void) t_start = jl_hrtime(); } -void jl_gc_set_max_memory(uint64_t max_mem) { +JL_DLLEXPORT void jl_gc_set_max_memory(uint64_t max_mem) +{ if (max_mem > 0 && max_mem < (uint64_t)1 << (sizeof(memsize_t) * 8 - 1)) { max_total_memory = max_mem; diff --git a/src/jl_exported_funcs.inc b/src/jl_exported_funcs.inc index 82bdfc1f5b7eb..7699dc8cdb904 100644 --- a/src/jl_exported_funcs.inc +++ b/src/jl_exported_funcs.inc @@ -199,6 +199,7 @@ XX(jl_gc_set_cb_pre_gc) \ XX(jl_gc_set_cb_root_scanner) \ XX(jl_gc_set_cb_task_scanner) \ + XX(jl_gc_set_max_memory) \ XX(jl_gc_sync_total_bytes) \ XX(jl_gc_total_hrtime) \ XX(jl_gdblookup) \ diff --git a/src/jloptions.c b/src/jloptions.c index f325452e19e41..812543a09399e 100644 --- a/src/jloptions.c +++ b/src/jloptions.c @@ -815,8 +815,6 @@ JL_DLLEXPORT void jl_parse_opts(int *argcp, char ***argvp) break; } jl_options.heap_size_hint = (uint64_t)(value * multiplier); - - jl_gc_set_max_memory(jl_options.heap_size_hint); } } if (jl_options.heap_size_hint == 0) diff --git a/src/julia.h b/src/julia.h index a34c1f06d0cc1..a5d3259ad0d3f 100644 --- a/src/julia.h +++ b/src/julia.h @@ -927,6 +927,8 @@ JL_DLLEXPORT void *jl_malloc_stack(size_t *bufsz, struct _jl_task_t *owner) JL_N JL_DLLEXPORT void jl_free_stack(void *stkbuf, size_t bufsz); JL_DLLEXPORT void jl_gc_use(jl_value_t *a); JL_DLLEXPORT uint64_t jl_gc_get_max_memory(void); +// Set GC memory trigger in bytes for greedy memory collecting +JL_DLLEXPORT void jl_gc_set_max_memory(uint64_t max_mem); JL_DLLEXPORT void jl_clear_malloc_data(void); diff --git a/src/julia_internal.h b/src/julia_internal.h index e06a834a80752..b932cc82be6ea 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -590,9 +590,6 @@ void jl_gc_run_all_finalizers(jl_task_t *ct); void jl_release_task_stack(jl_ptls_t ptls, jl_task_t *task); void jl_gc_add_finalizer_(jl_ptls_t ptls, void *v, void *f) JL_NOTSAFEPOINT; -// Set GC memory trigger in bytes for greedy memory collecting -void jl_gc_set_max_memory(uint64_t max_mem); - JL_DLLEXPORT void jl_gc_queue_binding(jl_binding_t *bnd) JL_NOTSAFEPOINT; void gc_setmark_buf(jl_ptls_t ptls, void *buf, uint8_t, size_t) JL_NOTSAFEPOINT;