Skip to content
This repository was archived by the owner on Mar 12, 2021. It is now read-only.

Commit 398e563

Browse files
authored
Merge pull request #556 from JuliaGPU/tb/split_reclaim
Fix SplittingPool reclaim.
2 parents 72882b2 + 0e7f8a9 commit 398e563

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/memory/split.jl

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ end
301301
function pool_alloc(sz)
302302
szclass = size_class(sz)
303303

304-
# round of the block size
304+
# round off the block size
305305
req_sz = sz
306306
roundoff = if szclass == SMALL
307307
SMALL_ROUNDOFF
@@ -422,12 +422,19 @@ function free(ptr)
422422
end
423423

424424
function reclaim(sz::Int=typemax(Int))
425-
freed = 0
425+
if !isempty(freed)
426+
blocks = Set(freed)
427+
empty!(freed)
428+
repopulate(blocks)
429+
incremental_compact!(blocks)
430+
end
431+
432+
freed_sz = 0
426433
for available in (available_huge, available_large, available_small)
427-
freed >= sz && break
428-
freed += reclaim!(available, sz-freed)
434+
freed_sz >= sz && break
435+
freed_sz += reclaim!(available, sz-freed_sz)
429436
end
430-
return freed
437+
return freed_sz
431438
end
432439

433440
used_memory() = mapreduce(sizeof, +, values(allocated); init=0)

0 commit comments

Comments
 (0)