Memory leak squashing

This commit is contained in:
Alex Yatskov 2015-12-17 18:50:05 +09:00
parent 18289e3c31
commit e11181807f

View File

@ -23,6 +23,7 @@
package goldsmith package goldsmith
import ( import (
"bytes"
"os" "os"
"path" "path"
"path/filepath" "path/filepath"
@ -126,7 +127,7 @@ func (gs *goldsmith) cleanupFiles() {
func (gs *goldsmith) exportFile(file *File) { func (gs *goldsmith) exportFile(file *File) {
defer func() { defer func() {
file.Buff.Reset() file.Buff = *bytes.NewBuffer(nil)
atomic.AddInt64(&gs.busy, -1) atomic.AddInt64(&gs.busy, -1)
}() }()
@ -221,6 +222,7 @@ func (gs *goldsmith) chain(s *stage, p Plugin) {
if proc.Process(s, f) { if proc.Process(s, f) {
dispatch(f) dispatch(f)
} else { } else {
f.Buff = *bytes.NewBuffer(nil)
atomic.AddInt64(&gs.busy, -1) atomic.AddInt64(&gs.busy, -1)
} }
}(file) }(file)