Skip to content

Commit 270fcff

Browse files
maleadtJeffBezanson
authored andcommitted
Clean-up the GC.gc interface. (#34401)
1 parent 60b60f1 commit 270fcff

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

base/gcutils.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,13 @@ Module with garbage collection utilities.
4949
"""
5050
module GC
5151

52+
# mirrored from julia.h
53+
const GC_AUTO = 0
54+
const GC_FULL = 1
55+
const GC_INCREMENTAL = 2
56+
5257
"""
53-
GC.gc()
54-
GC.gc(full::Bool)
58+
GC.gc([full=true])
5559
5660
Perform garbage collection. The argument `full` determines the kind of
5761
collection: A full collection (default) sweeps all objects, which makes the
@@ -61,8 +65,8 @@ so-called young objects.
6165
!!! warning
6266
Excessive use will likely lead to poor performance.
6367
"""
64-
gc() = ccall(:jl_gc_collect, Cvoid, (Cint,), 1)
65-
gc(full::Bool) = ccall(:jl_gc_collect, Cvoid, (Cint,), full ? 1 : 2)
68+
gc(full::Bool=true) =
69+
ccall(:jl_gc_collect, Cvoid, (Cint,), full ? GC_FULL : GC_INCREMENTAL)
6670

6771
"""
6872
GC.enable(on::Bool)

0 commit comments

Comments
 (0)