Running `crypto.PassphraseHash` in a loop allocates a lot of memory.
Golang is not always prudent about collecting the garbage from previous
runs, resulting in a OOM error on memory-pressured systems.
With a `maxMemoryBytes` of 128 MiB, this change reduces the maximum
resident memory for `fscrypt setup` to 141 MiB (was perviously 405 MiB)
Signed-off-by: Joe Richey <joerichey@google.com>
}
end := cpuTimeInNanoseconds()
+ // This uses a lot of memory, run the garbage collector
+ runtime.GC()
+
return time.Duration((end - begin) / costs.Parallelism), nil
}