From 46b5d7557c8ac23508ab251fb3ae6dec1d199cd8 Mon Sep 17 00:00:00 2001 From: Alex Arslan Date: Wed, 17 Jan 2018 12:13:32 -0800 Subject: [PATCH] Deprecate gc and gc_enable in favor of GC.gc and GC.enable We document that these functions should not generally be used, and yet they're exported from Base. This moves the two functions into their own submodule, Base.GC, and deprecates the exported functions. --- NEWS.md | 3 ++ base/deprecated.jl | 3 ++ base/exports.jl | 3 +- base/gcutils.jl | 22 +++++++--- doc/src/base/base.md | 4 +- doc/src/manual/faq.md | 2 +- stdlib/FileWatching/test/runtests.jl | 10 ++--- stdlib/Mmap/test/runtests.jl | 62 ++++++++++++++-------------- stdlib/SharedArrays/test/runtests.jl | 8 ++-- stdlib/SparseArrays/test/sparse.jl | 6 +-- stdlib/SuiteSparse/test/cholmod.jl | 2 +- test/ccall.jl | 2 +- test/channels.jl | 6 +-- test/codegen.jl | 4 +- test/core.jl | 62 ++++++++++++++-------------- test/misc.jl | 16 +++---- test/netload/memtest.jl | 4 +- test/perf/kernel/perf.jl | 2 +- test/perf/perfutil.jl | 2 +- test/perf/sort/perf.jl | 4 +- test/threads.jl | 2 +- 21 files changed, 122 insertions(+), 107 deletions(-) diff --git a/NEWS.md b/NEWS.md index 7e064afc111a1..6b474e0f53a06 100644 --- a/NEWS.md +++ b/NEWS.md @@ -966,6 +966,8 @@ Deprecated or removed * `ObjectIdDict` has been deprecated in favor of `IdDict{Any,Any}` ([#25210]). + * `gc` and `gc_enable` have been deprecated in favor of `GC.gc` and `GC.enable` ([#25616]). + Command-line option changes --------------------------- @@ -1217,3 +1219,4 @@ Command-line option changes [#25424]: https://github.com/JuliaLang/julia/issues/25424 [#25532]: https://github.com/JuliaLang/julia/issues/25532 [#25545]: https://github.com/JuliaLang/julia/issues/25545 +[#25616]: https://github.com/JuliaLang/julia/issues/25616 diff --git a/base/deprecated.jl b/base/deprecated.jl index b72db1016c290..b7e3181b6d61d 100644 --- a/base/deprecated.jl +++ b/base/deprecated.jl @@ -1573,6 +1573,9 @@ end @deprecate object_id objectid +@deprecate gc GC.gc +@deprecate gc_enable GC.enable + # issue #9053 if Sys.iswindows() function Filesystem.tempname(uunique::UInt32) diff --git a/base/exports.jl b/base/exports.jl index 667f81cd3d018..ff2264b31c01e 100644 --- a/base/exports.jl +++ b/base/exports.jl @@ -806,10 +806,9 @@ export include_dependency, # RTS internals + GC, finalizer, finalize, - gc, - gc_enable, precompile, # misc diff --git a/base/gcutils.jl b/base/gcutils.jl index cacce1119c1d9..525a350a4b81b 100644 --- a/base/gcutils.jl +++ b/base/gcutils.jl @@ -38,18 +38,28 @@ Immediately run finalizers registered for object `x`. finalize(@nospecialize(o)) = ccall(:jl_finalize_th, Cvoid, (Ptr{Cvoid}, Any,), Core.getptls(), o) +module GC + """ - gc() + GC.gc() + +Perform garbage collection. -Perform garbage collection. This should not generally be used. +!!! warning + Excessive use will likely lead to poor performance. """ gc(full::Bool=true) = ccall(:jl_gc_collect, Cvoid, (Int32,), full) """ - gc_enable(on::Bool) + GC.enable(on::Bool) Control whether garbage collection is enabled using a boolean argument (`true` for enabled, -`false` for disabled). Return previous GC state. Disabling garbage collection should be -used only with extreme caution, as it can cause memory use to grow without bound. +`false` for disabled). Return previous GC state. + +!!! warning + Disabling garbage collection should be used only with caution, as it can cause memory + use to grow without bound. """ -gc_enable(on::Bool) = ccall(:jl_gc_enable, Int32, (Int32,), on) != 0 +enable(on::Bool) = ccall(:jl_gc_enable, Int32, (Int32,), on) != 0 + +end # module GC diff --git a/doc/src/base/base.md b/doc/src/base/base.md index e4fa75f137069..e04d69e7836b5 100644 --- a/doc/src/base/base.md +++ b/doc/src/base/base.md @@ -326,8 +326,8 @@ Base.@functionloc ## Internals ```@docs -Base.gc -Base.gc_enable +Base.GC.gc +Base.GC.enable Meta.lower Meta.@lower Meta.parse(::AbstractString, ::Int) diff --git a/doc/src/manual/faq.md b/doc/src/manual/faq.md index 6a24562d18e13..d367791dad20f 100644 --- a/doc/src/manual/faq.md +++ b/doc/src/manual/faq.md @@ -10,7 +10,7 @@ session (technically, in module `Main`), it is always present. If memory usage is your concern, you can always replace objects with ones that consume less memory. For example, if `A` is a gigabyte-sized array that you no longer need, you can free the memory with `A = nothing`. The memory will be released the next time the garbage collector runs; you can force -this to happen with [`gc()`](@ref). Moreover, an attempt to use `A` will likely result in an error, because most methods are not defined on type `Nothing`. +this to happen with [`gc()`](@ref Base.GC.gc). Moreover, an attempt to use `A` will likely result in an error, because most methods are not defined on type `Nothing`. ### How can I modify the declaration of a type in my session? diff --git a/stdlib/FileWatching/test/runtests.jl b/stdlib/FileWatching/test/runtests.jl index ce90324aa0652..8aef7119e2c71 100644 --- a/stdlib/FileWatching/test/runtests.jl +++ b/stdlib/FileWatching/test/runtests.jl @@ -144,7 +144,7 @@ end end let a = Ref(0) make_unrooted_timer(a) - gc() + GC.gc() @test a[] == 1 end @@ -161,8 +161,8 @@ function test_12992() close(pfw) pfw = PollingFileWatcher(@__FILE__, 0.01) close(pfw) - gc() - gc() + GC.gc() + GC.gc() end # Make sure multiple close is fine @@ -176,8 +176,8 @@ function test2_12992() pfw = PollingFileWatcher(@__FILE__, 0.01) close(pfw) close(pfw) - gc() - gc() + GC.gc() + GC.gc() end test_12992() diff --git a/stdlib/Mmap/test/runtests.jl b/stdlib/Mmap/test/runtests.jl index 7ca20e7aa42b3..0face3bf6fd55 100644 --- a/stdlib/Mmap/test/runtests.jl +++ b/stdlib/Mmap/test/runtests.jl @@ -6,20 +6,20 @@ file = tempname() write(file, "Hello World\n") t = b"Hello World" @test Mmap.mmap(file, Array{UInt8,3}, (11,1,1)) == reshape(t,(11,1,1)) -gc(); gc() +GC.gc(); GC.gc() @test Mmap.mmap(file, Array{UInt8,3}, (1,11,1)) == reshape(t,(1,11,1)) -gc(); gc() +GC.gc(); GC.gc() @test Mmap.mmap(file, Array{UInt8,3}, (1,1,11)) == reshape(t,(1,1,11)) -gc(); gc() +GC.gc(); GC.gc() @test Mmap.mmap(file, Array{UInt8,3}, (11,0,1)) == Array{UInt8}(uninitialized, (0,0,0)) @test Mmap.mmap(file, Vector{UInt8}, (11,)) == t -gc(); gc() +GC.gc(); GC.gc() @test Mmap.mmap(file, Array{UInt8,2}, (1,11)) == t' -gc(); gc() +GC.gc(); GC.gc() @test Mmap.mmap(file, Array{UInt8,2}, (0,12)) == Array{UInt8}(uninitialized, (0,0)) m = Mmap.mmap(file, Array{UInt8,3}, (1,2,1)) @test m == reshape(b"He",(1,2,1)) -finalize(m); m=nothing; gc() +finalize(m); m=nothing; GC.gc() # constructors @test length(@inferred Mmap.mmap(file)) == 12 @@ -45,7 +45,7 @@ s = open(file) @test length(@inferred Mmap.mmap(s, Vector{Int8}, 12, 0; shared=false)) == 12 close(s) @test_throws ErrorException Mmap.mmap(file, Vector{Ref}) # must be bit-type -gc(); gc() +GC.gc(); GC.gc() s = open(f->f,file,"w") @test Mmap.mmap(file) == Vector{UInt8}() # requested len=0 on empty file @@ -54,7 +54,7 @@ s = open(file, "r+") m = Mmap.mmap(s,Vector{UInt8},12) m[:] = b"Hello World\n" Mmap.sync!(m) -close(s); finalize(m); m=nothing; gc() +close(s); finalize(m); m=nothing; GC.gc() @test open(x->read(x, String),file) == "Hello World\n" s = open(file, "r") @@ -71,39 +71,39 @@ close(s) for i = 0x01:0x0c @test length(Mmap.mmap(file, Vector{UInt8}, i)) == Int(i) end -gc(); gc() +GC.gc(); GC.gc() sz = filesize(file) s = open(file, "r+") m = Mmap.mmap(s, Vector{UInt8}, sz+1) @test length(m) == sz+1 # test growing @test m[end] == 0x00 -close(s); finalize(m); m=nothing; gc() +close(s); finalize(m); m=nothing; GC.gc() sz = filesize(file) s = open(file, "r+") m = Mmap.mmap(s, Vector{UInt8}, 1, sz) @test length(m) == 1 @test m[1] == 0x00 -close(s); finalize(m); m=nothing; gc() +close(s); finalize(m); m=nothing; GC.gc() sz = filesize(file) # test where offset is actually > than size of file; file is grown with zeroed bytes s = open(file, "r+") m = Mmap.mmap(s, Vector{UInt8}, 1, sz+1) @test length(m) == 1 @test m[1] == 0x00 -close(s); finalize(m); m=nothing; gc() +close(s); finalize(m); m=nothing; GC.gc() s = open(file, "r") m = Mmap.mmap(s) @test_throws ReadOnlyMemoryError m[5] = UInt8('x') # tries to setindex! on read-only array -finalize(m); m=nothing; gc() +finalize(m); m=nothing; GC.gc() write(file, "Hello World\n") s = open(file, "r") m = Mmap.mmap(s) close(s) -finalize(m); m=nothing; gc() +finalize(m); m=nothing; GC.gc() m = Mmap.mmap(file) s = open(file, "r+") c = Mmap.mmap(s) @@ -114,7 +114,7 @@ close(s) @test m[1] == UInt8('J') @test d[1] == UInt8('J') finalize(m); finalize(c); finalize(d) -m=nothing; c=nothing; d=nothing; gc() +m=nothing; c=nothing; d=nothing; GC.gc() write(file, "Hello World\n") @@ -122,10 +122,10 @@ s = open(file, "r") @test isreadonly(s) == true c = Mmap.mmap(s, Vector{UInt8}, (11,)) @test c == b"Hello World" -finalize(c); c=nothing; gc() +finalize(c); c=nothing; GC.gc() c = Mmap.mmap(s, Vector{UInt8}, (UInt16(11),)) @test c == b"Hello World" -finalize(c); c=nothing; gc() +finalize(c); c=nothing; GC.gc() @test_throws ArgumentError Mmap.mmap(s, Vector{UInt8}, (Int16(-11),)) @test_throws ArgumentError Mmap.mmap(s, Vector{UInt8}, (typemax(UInt),)) close(s) @@ -139,22 +139,22 @@ s = open(file, "r") str = readline(s) close(s) @test startswith(str, "Hellx World") -finalize(c); c=nothing; gc() +finalize(c); c=nothing; GC.gc() c = Mmap.mmap(file) @test c == b"Hellx World\n" -finalize(c); c=nothing; gc() +finalize(c); c=nothing; GC.gc() c = Mmap.mmap(file, Vector{UInt8}, 3) @test c == b"Hel" -finalize(c); c=nothing; gc() +finalize(c); c=nothing; GC.gc() s = open(file, "r") c = Mmap.mmap(s, Vector{UInt8}, 6) @test c == b"Hellx " close(s) -finalize(c); c=nothing; gc() +finalize(c); c=nothing; GC.gc() c = Mmap.mmap(file, Vector{UInt8}, 5, 6) @test c == b"World" -finalize(c); c=nothing; gc() +finalize(c); c=nothing; GC.gc() s = open(file, "w") write(s, "Hello World\n") @@ -167,7 +167,7 @@ for i = 1:12 @test m[i] == tdata[i] end @test_throws BoundsError m[13] -finalize(m); m=nothing; gc() +finalize(m); m=nothing; GC.gc() m = Mmap.mmap(file,Vector{UInt8},6) @test m[1] == b"H"[1] @@ -177,13 +177,13 @@ m = Mmap.mmap(file,Vector{UInt8},6) @test m[5] == b"o"[1] @test m[6] == b" "[1] @test_throws BoundsError m[7] -finalize(m); m=nothing; gc() +finalize(m); m=nothing; GC.gc() m = Mmap.mmap(file,Vector{UInt8},2,6) @test m[1] == b"W"[1] @test m[2] == b"o"[1] @test_throws BoundsError m[3] -finalize(m); m = nothing; gc() +finalize(m); m = nothing; GC.gc() s = open(file, "w") write(s, [0xffffffffffffffff, @@ -214,7 +214,7 @@ b = Mmap.mmap(s, BitArray, (17,19)) close(s) finalize(b); finalize(b0) b = nothing; b0 = nothing -gc() +GC.gc() open(file,"w") do f write(f,UInt64(1)) @@ -225,7 +225,7 @@ s = open(file, "r+") m = Mmap.mmap(s, BitArray, (72,)) @test Base._check_bitarray_consistency(m) @test length(m) == 72 -close(s); finalize(m); m = nothing; gc() +close(s); finalize(m); m = nothing; GC.gc() rm(file) # Mmap.mmap with an offset @@ -249,7 +249,7 @@ A4 = Mmap.mmap(s, Matrix{Int}, (m,150), convert(Int64, (2+150*m)*sizeof(Int))) close(s) finalize(A2); finalize(A3); finalize(A4) A2 = A3 = A4 = nothing -gc() +GC.gc() rm(fname) # Mmap.Anonymous @@ -289,7 +289,7 @@ n = similar(m, (2,2)) n = similar(m, 12) @test length(n) == 12 @test size(n) == (12,) -finalize(m); m = nothing; gc() +finalize(m); m = nothing; GC.gc() # test #14885 file = tempname() @@ -297,9 +297,9 @@ touch(file) open(file, "r+") do s A = Mmap.mmap(s, Vector{UInt8}, (10,), 0) Mmap.sync!(A) - finalize(A); A = nothing; gc() + finalize(A); A = nothing; GC.gc() A = Mmap.mmap(s, Vector{UInt8}, (10,), 1) Mmap.sync!(A) - finalize(A); A = nothing; gc() + finalize(A); A = nothing; GC.gc() end rm(file) diff --git a/stdlib/SharedArrays/test/runtests.jl b/stdlib/SharedArrays/test/runtests.jl index 6dcea0aaa3b73..a4bfa65d4944e 100644 --- a/stdlib/SharedArrays/test/runtests.jl +++ b/stdlib/SharedArrays/test/runtests.jl @@ -145,9 +145,9 @@ finalize(S) # call gc 3 times to avoid unlink: operation not permitted (EPERM) on Windows S = nothing -@everywhere gc() -@everywhere gc() -@everywhere gc() +@everywhere GC.gc() +@everywhere GC.gc() +@everywhere GC.gc() rm(fn); rm(fn2); rm(fn3) ### Utility functions @@ -288,7 +288,7 @@ let id = a1.id aorig = nothing a1 = remotecall_fetch(fill!, id_other, a1, 1.0) - gc(); gc() + GC.gc(); GC.gc() a1 = remotecall_fetch(fill!, id_other, a1, 1.0) @test haskey(SharedArrays.sa_refs, id) finalize(a1) diff --git a/stdlib/SparseArrays/test/sparse.jl b/stdlib/SparseArrays/test/sparse.jl index 99441c1165799..909a47b070249 100644 --- a/stdlib/SparseArrays/test/sparse.jl +++ b/stdlib/SparseArrays/test/sparse.jl @@ -1214,7 +1214,7 @@ end times = Float64[0,0,0] best = [typemax(Float64), 0] for searchtype in [0, 1, 2] - gc() + GC.gc() tres = @timed test_getindex_algs(S, I, J, searchtype) res[searchtype+1] = tres[1] times[searchtype+1] = tres[2] @@ -1270,9 +1270,9 @@ end for I in IA Isorted = sort(I) for S in SA - gc() + GC.gc() ru = @timed S[I, J] - gc() + GC.gc() rs = @timed S[Isorted, Jsorted] if debug @printf(" %7d | %7d | %7d | %4.2e | %4.2e | %4.2e | %4.2e |\n", round(Int,nnz(S)/S.n), length(I), length(J), rs[2], ru[2], rs[3], ru[3]) diff --git a/stdlib/SuiteSparse/test/cholmod.jl b/stdlib/SuiteSparse/test/cholmod.jl index 1efa24ecfba51..0275adb3e082d 100644 --- a/stdlib/SuiteSparse/test/cholmod.jl +++ b/stdlib/SuiteSparse/test/cholmod.jl @@ -625,7 +625,7 @@ end A = Float64[10 1 1 1; 1 10 0 0; 1 0 10 0; 1 0 0 10] @test sparse(cholfact(sparse(A))) ≈ A end -gc() +GC.gc() @testset "Issue 11747 - Wrong show method defined for FactorComponent" begin v = cholfact(sparse(Float64[ 10 1 1 1; 1 10 0 0; 1 0 10 0; 1 0 0 10])).L diff --git a/test/ccall.jl b/test/ccall.jl index 4250591b2ac4f..178030de8cecb 100644 --- a/test/ccall.jl +++ b/test/ccall.jl @@ -1295,7 +1295,7 @@ struct Bits22734 <: Abstract22734 y::Float64 end function cb22734(ptr::Ptr{Cvoid}) - gc() + GC.gc() obj = unsafe_pointer_to_objref(ptr)::Bits22734 obj.x + obj.y end diff --git a/test/channels.jl b/test/channels.jl index 10301bd3e804a..97d87c5b9b99e 100644 --- a/test/channels.jl +++ b/test/channels.jl @@ -232,14 +232,14 @@ end # test for yield/wait/event failures @noinline garbage_finalizer(f) = finalizer(f, "gar" * "bage") let t, run = Ref(0) - gc_enable(false) + GC.enable(false) # test for finalizers trying to yield leading to failed attempts to context switch garbage_finalizer((x) -> (run[] += 1; sleep(1))) garbage_finalizer((x) -> (run[] += 1; yield())) garbage_finalizer((x) -> (run[] += 1; yieldto(@task () -> ()))) t = @task begin - gc_enable(true) - gc() + GC.enable(true) + GC.gc() end oldstderr = STDERR local newstderr, errstream diff --git a/test/codegen.jl b/test/codegen.jl index 0f5909b32d665..f01fbb00c52aa 100644 --- a/test/codegen.jl +++ b/test/codegen.jl @@ -234,13 +234,13 @@ let was_gced = false a = Ref(1) use(x); use(a); use(y) c = Ref(3) - gc() + GC.gc() assert_not_gced() use(x) use(c) end foo22770() - gc() + GC.gc() @test was_gced end diff --git a/test/core.jl b/test/core.jl index b6040eb90ea4e..b6793fc53d1f4 100644 --- a/test/core.jl +++ b/test/core.jl @@ -3,10 +3,10 @@ # test core language features using Random +using SparseArrays const Bottom = Union{} -using SparseArrays # For curmod_* include("testenv.jl") @@ -905,7 +905,7 @@ let A = [1] finalize(A) @test x == 1 A = 0 - gc(); gc() + GC.gc(); GC.gc() @test x == 1 end @@ -1475,7 +1475,7 @@ end function foo4075(f::Foo4075, s::Symbol) x = getfield(f,s) - gc() + GC.gc() x end @@ -2473,10 +2473,10 @@ mutable struct Obj; x; end wref = [] mk_wr(ref, wref) test_wr(ref, wref) - gc() + GC.gc() test_wr(ref, wref) pop!(ref) - gc() + GC.gc() @test wref[1].value === nothing end test_wr() @@ -2553,7 +2553,7 @@ try val::Bar{T} end end -gc() +GC.gc() redirect_stdout(OLD_STDOUT) close(file) rm(fname) @@ -3097,7 +3097,7 @@ struct Array_512_Uint8 d511::UInt8 d512::UInt8 end -gc() +GC.gc() # issue #10867 @test collect(enumerate((Tuple,Int))) == [(1,Tuple), (2,Int)] @@ -3653,11 +3653,11 @@ let # obj should be marked for promotion after the second gc and be promoted # after the third GC # GC_CLEAN; age = 0 - gc(false) + GC.gc(false) # GC_CLEAN; age = 1 - gc(false) + GC.gc(false) # GC_QUEUED; age = 1 - gc(false) + GC.gc(false) # GC_MARKED; age = 1 finalize(obj) @test finalized == 1 @@ -3666,14 +3666,14 @@ end # check if finalizers for the old gen can be triggered manually # PR #14181 let - # The following three `gc(false)` clears the `finalizer_list`. It is + # The following three `GC.gc(false)` clears the `finalizer_list`. It is # not strictly necessary to make the test pass but should make the failure # more repeatable if something breaks. - gc(false) + GC.gc(false) # At least: GC_CLEAN; age = 1 - gc(false) + GC.gc(false) # At least: GC_QUEUED; age = 1 - gc(false) + GC.gc(false) # all objects in `finalizer_list` are now moved to `finalizer_list_marked` obj1 = Ref(1) @@ -3719,9 +3719,9 @@ let i = 9.0 end # Make sure the old f() method is GC'd if it was not rooted properly -gc() -gc() -gc() +GC.gc() +GC.gc() +GC.gc() # Run again. g() @@ -3982,9 +3982,9 @@ let ary = Vector{Any}(uninitialized, 10) ary = Vector{Any}(uninitialized, n) # Try to free the previous buffer that was filled with random content # and to increase the chance of getting a non-zero'd buffer next time - gc() - gc() - gc() + GC.gc() + GC.gc() + GC.gc() ccall(:jl_array_grow_beg, Cvoid, (Any, Csize_t), ary, 4) ccall(:jl_array_del_beg, Cvoid, (Any, Csize_t), ary, 4) ccall(:jl_array_grow_end, Cvoid, (Any, Csize_t), ary, n) @@ -4027,16 +4027,16 @@ end end # disable GC to make sure no collection/promotion happens # when we are constructing the objects -let gc_enabled13995 = gc_enable(false) +let gc_enabled13995 = GC.enable(false) finalized13995 = [false, false, false, false] create_dead_object13995(finalized13995) - gc_enable(true) + GC.enable(true) # obj is unreachable and young, a single young gc should collect it # and trigger all the finalizers. - gc(false) - gc_enable(false) + GC.gc(false) + GC.enable(false) @test finalized13995 == [true, true, true, true] - gc_enable(gc_enabled13995) + GC.enable(gc_enabled13995) end # issue #15283 @@ -4831,7 +4831,7 @@ end # issue #17255, take `deferred_alloc` into account # when calculating total allocation size. @noinline function f17255(n) - gc_enable(false) + GC.enable(false) b0 = Base.gc_bytes() local a for i in 1:n @@ -4845,7 +4845,7 @@ end return true, a end @test f17255(10000)[1] -gc_enable(true) +GC.enable(true) # issue #18710 bad_tvars() where {T} = 1 @@ -5023,7 +5023,7 @@ if Sys.WORD_SIZE == 64 try # Do no touch the string to avoid triggering OOM slot[] = Base._string_n(2^32) - gc(false) + GC.gc(false) catch ex # This can happen if there's a virtual address size limit @test isa(ex, OutOfMemoryError) @@ -5032,13 +5032,13 @@ if Sys.WORD_SIZE == 64 return end @noinline function tester20360() - gc() - # Makes sure the string is rooted during the `gc(false)` + GC.gc() + # Makes sure the string is rooted during the `GC.gc(false)` # but is not before the last gc in this function. slot = Ref{Any}() test_large_string20360(slot) slot[] = nothing - gc() + GC.gc() return end @test_nowarn tester20360() diff --git a/test/misc.jl b/test/misc.jl index eafcbd35003a7..8e4173c8090b3 100644 --- a/test/misc.jl +++ b/test/misc.jl @@ -83,12 +83,12 @@ let # test the process title functions, issue #9957 @test Sys.get_process_title() == oldtitle end -# test gc_enable/disable -@test gc_enable(true) -@test gc_enable(false) -@test gc_enable(false) == false -@test gc_enable(true) == false -@test gc_enable(true) +# test GC.enable/disable +@test GC.enable(true) +@test GC.enable(false) +@test GC.enable(false) == false +@test GC.enable(true) == false +@test GC.enable(true) # test methodswith # `methodswith` relies on exported symbols @@ -146,7 +146,7 @@ let c = Ref(0), t2 = @schedule (wait(); c[] += 99) @test c[] == 0 f6597(c) - gc() # this should run the finalizer for t + GC.gc() # this should run the finalizer for t @test c[] == 1 yield() @test c[] == 1 @@ -646,4 +646,4 @@ end module A export missing varinfo(A) -end \ No newline at end of file +end diff --git a/test/netload/memtest.jl b/test/netload/memtest.jl index 78a203b314202..dade493720c13 100644 --- a/test/netload/memtest.jl +++ b/test/netload/memtest.jl @@ -48,14 +48,14 @@ function mtest_create_strings() for i in 1:10^8 string("$i") end - gc() + GC.gc() end function mtest_remotecall_fetch() for i in 1:10^5 remotecall_fetch(myid, 1) end - gc() + GC.gc() end run_mtest("create_strings", () -> mtest_create_strings()) diff --git a/test/perf/kernel/perf.jl b/test/perf/kernel/perf.jl index 4ccb0e2d590bd..cc519ac37db33 100644 --- a/test/perf/kernel/perf.jl +++ b/test/perf/kernel/perf.jl @@ -21,7 +21,7 @@ function listn1n2(n1::Int,n2::Int) end @timeit listn1n2(1,10^6) "cons" "List concatenation" -gc() +GC.gc() # issue #1211 include("ziggurat.jl") diff --git a/test/perf/perfutil.jl b/test/perf/perfutil.jl index 7c923aa3612a0..b13d372d0d3ef 100644 --- a/test/perf/perfutil.jl +++ b/test/perf/perfutil.jl @@ -65,7 +65,7 @@ macro output_timings(t,name,desc,group) elseif print_output @printf "julia,%s,%f,%f,%f,%f\n" $name minimum($t) maximum($t) mean($t) std($t) end - gc() + GC.gc() end end diff --git a/test/perf/sort/perf.jl b/test/perf/sort/perf.jl index 0ec5373ecc429..9e589ef889fb0 100644 --- a/test/perf/sort/perf.jl +++ b/test/perf/sort/perf.jl @@ -20,7 +20,7 @@ if codespeed for s in sorts if s == InsertionSort && size != 2^6; continue; end data = Vector{T}(uninitialized, size) - gc() + GC.gc() ## Random name = "$(typename)_$(size)_$(string(s)[1:end-5])_random" @@ -45,7 +45,7 @@ else if s == InsertionSort && logsize >=14 continue end #Too slow println(s, s==RadixSort, s, typename, typename==AbstractString, logsize) data = Vector{T}(uninitialized, size) - gc() + GC.gc() ## Random name = "$(typename)_$(logsize)_$(string(s)[1:end-5])_random" diff --git a/test/threads.jl b/test/threads.jl index 12b3cffd0454e..f28bc40c991fe 100644 --- a/test/threads.jl +++ b/test/threads.jl @@ -124,7 +124,7 @@ function threaded_gc_locked(::Type{LockT}) where LockT @threads for i = 1:20 @test lock(critical) === nothing @test islocked(critical) - gc(false) + GC.gc(false) @test unlock(critical) === nothing end @test !islocked(critical)