Description
mheap.reclaimList
rotates swept spans to the back of whichever busy list it's sweeping and assumes that as soon as it encounters an already-swept span that it's done processing the whole list. However, gosweepone
(used by proportional sweeping and the background sweeper) can sweep arbitrary spans, including spans that are in the middle of some busy list. If reclaimList
encounters such a span, it won't sweep any more spans in that busy list. Eventually this can cause mheap.reclaim
to fail even though there are sweepable spans, which leads to premature heap growth.
This is easy to demonstrate by adding the following to the end of reclaimList
and running all.bash:
for s := list.first; s != nil; s = s.next {
if s.sweepgen == sg-2 {
println("unswept span", s)
}
}
This has been a problem for many releases, but AFAIK there aren't any specific reports of it. I found it by inspection.
/cc @RLH