diff --git a/src/libexpr/nix_api_expr.cc b/src/libexpr/nix_api_expr.cc index 1eb3693a2..84d55ec13 100644 --- a/src/libexpr/nix_api_expr.cc +++ b/src/libexpr/nix_api_expr.cc @@ -132,9 +132,12 @@ void nix_gc_decref(const void *p) { // todo: else { throw? } } +void nix_gc_now() { GC_gcollect(); } + #else -void nix_gc_incref(const void *){}; -void nix_gc_decref(const void *){}; +void nix_gc_incref(const void *) {} +void nix_gc_decref(const void *) {} +void nix_gc_now() {} #endif void nix_gc_register_finalizer(void *obj, void *cd, diff --git a/src/libexpr/nix_api_expr.h b/src/libexpr/nix_api_expr.h index ae2806343..9efb3dde1 100644 --- a/src/libexpr/nix_api_expr.h +++ b/src/libexpr/nix_api_expr.h @@ -128,6 +128,13 @@ void nix_gc_incref(const void *); */ void nix_gc_decref(const void *); +/** + * @brief Trigger the garbage collector manually + * + * You should not need to do this, but it can be useful for debugging. + */ +void nix_gc_now(); + /** * @brief Register a callback that gets called when the object is garbage * collected.