volume: fix memory leak

This commit is contained in:
Chris Lu 2020-03-10 13:31:23 -07:00
parent d214cefc2e
commit 43e6261579

View file

@ -342,6 +342,7 @@ func (v *Volume) copyDataAndGenerateIndexFile(dstName, idxName string, prealloca
defer dst.Close() defer dst.Close()
nm := needle_map.NewMemDb() nm := needle_map.NewMemDb()
defer nm.Close()
scanner := &VolumeFileScanner4Vacuum{ scanner := &VolumeFileScanner4Vacuum{
v: v, v: v,
@ -370,7 +371,9 @@ func copyDataBasedOnIndexFile(srcDatName, srcIdxName, dstDatName, datIdxName str
defer dstDatBackend.Close() defer dstDatBackend.Close()
oldNm := needle_map.NewMemDb() oldNm := needle_map.NewMemDb()
defer oldNm.Close()
newNm := needle_map.NewMemDb() newNm := needle_map.NewMemDb()
defer newNm.Close()
if err = oldNm.LoadFromIdx(srcIdxName); err != nil { if err = oldNm.LoadFromIdx(srcIdxName); err != nil {
return return
} }