diff --git a/src/array.c b/src/array.c index 5226c729d32e7..c7f71c9695e87 100644 --- a/src/array.c +++ b/src/array.c @@ -479,6 +479,7 @@ JL_DLLEXPORT jl_value_t *jl_array_to_string(jl_array_t *a) return o; } } + jl_gc_count_freed(jl_array_nbytes(a)); a->nrows = 0; a->length = 0; a->maxsize = 0; diff --git a/src/gc.c b/src/gc.c index d577c42d4859b..b298a5fa9571f 100644 --- a/src/gc.c +++ b/src/gc.c @@ -1128,6 +1128,13 @@ void jl_gc_count_allocd(size_t sz) JL_NOTSAFEPOINT jl_atomic_load_relaxed(&ptls->gc_num.allocd) + sz); } +void jl_gc_count_freed(size_t sz) JL_NOTSAFEPOINT +{ + jl_ptls_t ptls = jl_current_task->ptls; + jl_atomic_store_relaxed(&ptls->gc_num.freed, + jl_atomic_load_relaxed(&ptls->gc_num.freed) + sz); +} + static void combine_thread_gc_counts(jl_gc_num_t *dest) JL_NOTSAFEPOINT { int gc_n_threads; diff --git a/src/gc.h b/src/gc.h index 23e73eced6eb8..6ad521abe8c42 100644 --- a/src/gc.h +++ b/src/gc.h @@ -622,8 +622,6 @@ void gc_stats_big_obj(void); // For debugging void gc_count_pool(void); -size_t jl_array_nbytes(jl_array_t *a) JL_NOTSAFEPOINT; - JL_DLLEXPORT void jl_enable_gc_logging(int enable); JL_DLLEXPORT uint32_t jl_get_num_stack_mappings(void); void _report_gc_finished(uint64_t pause, uint64_t freed, int full, int recollect) JL_NOTSAFEPOINT; diff --git a/src/julia_internal.h b/src/julia_internal.h index 85ce95b65613d..d4b81d527aa86 100644 --- a/src/julia_internal.h +++ b/src/julia_internal.h @@ -569,7 +569,9 @@ JL_DLLEXPORT void JL_NORETURN jl_throw_out_of_memory_error(void); JL_DLLEXPORT int64_t jl_gc_diff_total_bytes(void) JL_NOTSAFEPOINT; JL_DLLEXPORT int64_t jl_gc_sync_total_bytes(int64_t offset) JL_NOTSAFEPOINT; void jl_gc_track_malloced_array(jl_ptls_t ptls, jl_array_t *a) JL_NOTSAFEPOINT; +size_t jl_array_nbytes(jl_array_t *a) JL_NOTSAFEPOINT; void jl_gc_count_allocd(size_t sz) JL_NOTSAFEPOINT; +void jl_gc_count_freed(size_t sz) JL_NOTSAFEPOINT; 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;