Skip to content

Commit 451ca7d

Browse files
authored
Allow disabling eager GC (#634)
1 parent 24ad256 commit 451ca7d

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

docs/src/index.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,9 @@ Template of `LocalPreferences.toml` with all options:
136136
137137
```toml
138138
[AMDGPU]
139+
# If `true` (default), eagerly run GC to keep the pool from growing too big.
140+
# GC is triggered during new allocatoins or synchronization points.
141+
eager_gc = false
139142
# If `true` then use ROCm libraries provided by artifacts.
140143
# However, not all ROCm libraries are available as artifacts.
141144
use_artifacts = false

src/memory.jl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,16 @@ function account!(stats::MemoryStats, bytes::Integer)
110110
Base.@atomic stats.live += bytes
111111
end
112112

113+
const EAGER_GC::Ref{Bool} = Ref{Bool}(@load_preference("eager_gc", true))
114+
115+
function eager_gc!(flag::Bool)
116+
global EAGER_GC[] = flag
117+
@set_preferences!("eager_gc" => flag)
118+
end
119+
113120
function maybe_collect(; blocking::Bool = false)
121+
EAGER_GC[] || return
122+
114123
stats = memory_stats()
115124
current_time = time()
116125

0 commit comments

Comments
 (0)