diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 7a8511dc5..2ca993ab0 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -267,6 +267,7 @@ func (i *Image) makeStale(rect image.Rectangle) { return } + origNum := len(i.staleRegions) i.staleRegions = i.appendRegionsForDrawTriangles(i.staleRegions) if !rect.Empty() { i.staleRegions = append(i.staleRegions, rect) @@ -274,6 +275,11 @@ func (i *Image) makeStale(rect image.Rectangle) { i.clearDrawTrianglesHistory() + // Clear pixels to save memory. + for _, r := range i.staleRegions[origNum:] { + i.basePixels.Clear(r.Min.X, r.Min.Y, r.Dx(), r.Dy()) + } + // Don't have to call makeStale recursively here. // Restoring is done after topological sorting is done. // If an image depends on another stale image, this means that