Skip to content

Commit

Permalink
export jl_gc_set_max_memory (JuliaLang#47545) (#124)
Browse files Browse the repository at this point in the history
Also initialize it later, outside option parsing, so that modifying jl_options
before calling jl_init works.

Co-authored-by: Jeff Bezanson <[email protected]>
  • Loading branch information
d-netto and JeffBezanson committed Dec 21, 2023
1 parent dad5588 commit 2865ebc
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 6 deletions.
3 changes: 2 additions & 1 deletion src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/jl_exported_funcs.inc
Original file line number Diff line number Diff line change
Expand Up @@ -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) \
Expand Down
2 changes: 0 additions & 2 deletions src/jloptions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions src/julia.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
3 changes: 0 additions & 3 deletions src/julia_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 2865ebc

Please sign in to comment.