Skip to content

Commit

Permalink
feat: stop GC while running analysis
Browse files Browse the repository at this point in the history
  • Loading branch information
dundee committed Sep 22, 2021
1 parent ca33d97 commit 54e7020
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions report/export.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"io"
"os"
"runtime/debug"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -83,6 +84,7 @@ func (ui *UI) AnalyzePath(path string, _ *analyze.Dir) error {
wait.Add(1)
go func() {
defer wait.Done()
defer debug.SetGCPercent(debug.SetGCPercent(-1))
dir = ui.Analyzer.AnalyzeDir(path, ui.CreateIgnoreFunc())
}()

Expand Down
2 changes: 2 additions & 0 deletions stdout/stdout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"io"
"math"
"runtime"
"runtime/debug"
"sort"
"sync"
"time"
Expand Down Expand Up @@ -131,6 +132,7 @@ func (ui *UI) AnalyzePath(path string, _ *analyze.Dir) error {
wait.Add(1)
go func() {
defer wait.Done()
defer debug.SetGCPercent(debug.SetGCPercent(-1))
dir = ui.Analyzer.AnalyzeDir(path, ui.CreateIgnoreFunc())
}()

Expand Down
4 changes: 3 additions & 1 deletion tui/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"os"
"runtime"
"runtime/debug"
"strings"

"github.com/dundee/gdu/v5/build"
Expand Down Expand Up @@ -53,8 +54,9 @@ func (ui *UI) AnalyzePath(path string, parentDir *analyze.Dir) error {
go ui.updateProgress()

go func() {
defer debug.SetGCPercent(debug.SetGCPercent(-1))
currentDir := ui.Analyzer.AnalyzeDir(path, ui.CreateIgnoreFunc())
runtime.GC()
debug.FreeOSMemory()

if parentDir != nil {
currentDir.Parent = parentDir
Expand Down

0 comments on commit 54e7020

Please sign in to comment.