Skip to content

Commit b0ed147

Browse files
maleadtJeffBezanson
authored andcommitted
Simplify the GC.gc interface. (#34303)
1 parent 41501a5 commit b0ed147

File tree

2 files changed

+8
-18
lines changed

2 files changed

+8
-18
lines changed

base/gcutils.jl

+8-17
Original file line numberDiff line numberDiff line change
@@ -49,29 +49,20 @@ Module with garbage collection utilities.
4949
"""
5050
module GC
5151

52-
# @enum-like structure
53-
struct CollectionType
54-
x::Int
55-
end
56-
Base.cconvert(::Type{Cint}, collection::CollectionType) = Cint(collection.x)
57-
58-
const Auto = CollectionType(0)
59-
const Full = CollectionType(1)
60-
const Incremental = CollectionType(2)
61-
6252
"""
63-
GC.gc(full::Bool=true)
64-
GC.gc(collection::CollectionType)
53+
GC.gc()
54+
GC.gc(full::Bool)
6555
66-
Perform garbage collection. The argument `full` determines whether a full, but more costly
67-
collection is performed. Otherwise, heuristics are used to determine which type of
68-
collection is needed. For exact control, pass an argument of type `CollectionType`.
56+
Perform garbage collection. The argument `full` determines the kind of collection: A full
57+
collection scans all objects, while an incremental collection only scans so-called young
58+
objects and is much quicker. If called without an argument, heuristics are used to determine
59+
which type of collection is needed.
6960
7061
!!! warning
7162
Excessive use will likely lead to poor performance.
7263
"""
73-
gc(full::Bool=true) = ccall(:jl_gc_collect, Cvoid, (Cint,), full)
74-
gc(collection::CollectionType) = ccall(:jl_gc_collect, Cvoid, (Cint,), collection)
64+
gc() = ccall(:jl_gc_collect, Cvoid, (Cint,), 0)
65+
gc(full::Bool) = ccall(:jl_gc_collect, Cvoid, (Cint,), full ? 1 : 2)
7566

7667
"""
7768
GC.enable(on::Bool)

test/misc.jl

-1
Original file line numberDiff line numberDiff line change
@@ -801,7 +801,6 @@ end
801801
@testset "GC utilities" begin
802802
GC.gc()
803803
GC.gc(true); GC.gc(false)
804-
GC.gc(GC.Auto); GC.gc(GC.Full); GC.gc(GC.Incremental)
805804

806805
GC.safepoint()
807806
end

0 commit comments

Comments
 (0)