This now puts gc and gc_enable into Base.GC as GC.gc and GC.enable, and exports the GC module from Base. gc is exported from GC , so if you do using GC you get gc but not enable . ararslan force-pushed the aa/stop-exporting-gc-stuff branch from 2d7d006 to f3fb539 Jan 18, 2018, gc_enable(on::Bool) Control whether garbage collection is enabled using a boolean argument (true for enabled, false for disabled). Returns previous GC state. Disabling garbage collection should be used only with extreme caution, as it can cause memory use to grow without bound.
When single-threaded, code could call the internal jl_gc_enable_finalizers C function to prevent finalizers from being scheduled inside a critical region. Internally, this is used inside some functions (such as our C locks) to prevent recursion when doing certain operations (incremental package loading, codegen, etc.).
Since Julia ‘s GC is precise, it needs to maintain correct rooting information for any value that may be referenced at any time GC may occur. These places are known as safepoints and in the function local context, we extend this designation to any function call that may recursively end up at a safepoint.
GC.enable(on::Bool) Control whether garbage collection is enabled using a boolean argument (true for enabled, false for disabled). Return previous GC state.
A simple use of this script is from the command line. Assuming that julia -config.jl is located in /usr/local/ julia /share/ julia , it can be invoked on the command line directly and takes any combination of 3 flags: /usr/local/ julia /share/ julia / julia -config.jl Usage: julia -config [–cflags|–ldflags|–ldlibs], 8/31/2015 · julia > gc_enable (false) true julia > include ( repo.jl ) Julia Version 0.4.0-pre + 7113 Commit 092 bcf4 * (2015-08-31 17: 47 UTC) Platform Info: System: Darwin (x86_64-apple-darwin14.5.0) CPU: Intel (R) Core (TM) i7-4870 HQ CPU @ 2.50 GHz WORD_SIZE: 64 BLAS: libopenblas (USE64BITINT NO_AFFINITY NEHALEM) LAPACK: libopenblas LIBM: libopenlibm LLVM: libLLVM.
julia > GC. enable (false) true julia > show (stdout, MIME text/html , methods (gcd)) MethodError (f = typeof (Base. show)(), args = (Core. CoreSTDOUT (), Base. Multimedia. MIME{Symbol ( text/html )}, Base. MethodList (ms = Array{Method, (8,)}[ Base. GMP. gcd (…), Base. gcd (…), Base. gcd (…), Base. gcd (…), Base. gcd (…), Base. gcd (…), Base. gcd (…
julia > x = rand(10^6) julia > @time f(x) 0.019049 seconds (16 allocations: 45.777 MiB, 18.59% gc time) julia > @time fdot(x) 0.002790 seconds (6 allocations: 7.630 MiB) julia > @time f.(x) 0.002626 seconds (8 allocations: 7.630 MiB)