From 860de28a28f28430f074494979876111ec287c24 Mon Sep 17 00:00:00 2001 From: Steve Yen Date: Thu, 7 Jan 2016 17:59:37 -0800 Subject: [PATCH] fix memory leak by closing batches in batchRows() --- index/firestorm/firestorm.go | 3 +++ index/upside_down/upside_down.go | 3 +++ 2 files changed, 6 insertions(+) diff --git a/index/firestorm/firestorm.go b/index/firestorm/firestorm.go index ea721334..7726f1ad 100644 --- a/index/firestorm/firestorm.go +++ b/index/firestorm/firestorm.go @@ -194,6 +194,9 @@ func (f *Firestorm) batchRows(writer store.KVWriter, rowsOfRows [][]index.IndexR // prepare batch wb := writer.NewBatch() + defer func() { + _ = wb.Close() + }() var kbuf []byte var vbuf []byte diff --git a/index/upside_down/upside_down.go b/index/upside_down/upside_down.go index 1b57f990..549da868 100644 --- a/index/upside_down/upside_down.go +++ b/index/upside_down/upside_down.go @@ -139,6 +139,9 @@ func (udc *UpsideDownCouch) batchRows(writer store.KVWriter, addRows []UpsideDow // prepare batch wb := writer.NewBatch() + defer func() { + _ = wb.Close() + }() // buffer to work with rowBuf := GetRowBuffer()