Skip to content

Commit 857644f

Browse files
authored
Do full GC if pressure is high (#645)
1 parent 18f73d3 commit 857644f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/memory.jl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ function maybe_collect(; blocking::Bool = false)
143143
min_pressure = blocking ? 0.5 : 0.75
144144
pressure < min_pressure && return
145145

146+
# TODO take allocations into account
147+
# if pressure is high but we didn't allocate - don't collect
148+
# otherwise try hard
149+
146150
# Check that we don't collect too often.
147151
gc_rate = stats.last_gc_time / (current_time - stats.last_time)
148152
# Tolerate 5% GC time.
@@ -160,7 +164,7 @@ function maybe_collect(; blocking::Bool = false)
160164
# Call the GC.
161165
Base.@atomic stats.last_time = current_time
162166
pre_gc_live = stats.live
163-
gc_time = Base.@elapsed GC.gc(false)
167+
gc_time = Base.@elapsed GC.gc(pressure > 0.9 ? true : false)
164168
post_gc_live = stats.live
165169

166170
# Update stats.

0 commit comments

Comments
 (0)