From fcf5b6cc93e2fc004ab63a814c0f924b44da6987 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sat, 15 Jan 2022 14:30:18 -0800 Subject: [PATCH] delete only when not used --- weed/filesys/page_writer/chunked_stream_writer.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/weed/filesys/page_writer/chunked_stream_writer.go b/weed/filesys/page_writer/chunked_stream_writer.go index be5f7ad2d..4bc49765b 100644 --- a/weed/filesys/page_writer/chunked_stream_writer.go +++ b/weed/filesys/page_writer/chunked_stream_writer.go @@ -100,10 +100,10 @@ func (cw *ChunkedStreamWriter) saveOneChunk(memChunk *MemChunk, logicChunkIndex for t := memChunk.usage.head.next; t != memChunk.usage.tail; t = t.next { reader := util.NewBytesReader(memChunk.buf[t.StartOffset:t.stopOffset]) cw.saveToStorageFn(reader, int64(logicChunkIndex)*cw.ChunkSize+t.StartOffset, t.Size(), func() { - delete(cw.activeChunks, logicChunkIndex) atomic.AddInt32(&referenceCounter, -1) if atomic.LoadInt32(&referenceCounter) == 0 { mem.Free(memChunk.buf) + delete(cw.activeChunks, logicChunkIndex) } }) }