From c9c577259e541fe1f6f4ee31bd19f12b07846325 Mon Sep 17 00:00:00 2001 From: Martin Sumner Date: Fri, 19 Jul 2019 13:37:27 +0100 Subject: [PATCH] Need to binary copy the header Otherwise the whole binary is kept in memory ... and the SST memory footprint is much bigger. --- src/leveled_sst.erl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/leveled_sst.erl b/src/leveled_sst.erl index e1a9d98..acabb08 100644 --- a/src/leveled_sst.erl +++ b/src/leveled_sst.erl @@ -675,7 +675,7 @@ reader({get_kvrange, StartKey, EndKey, ScanWidth, SegList, LowLastMod}, {_ID, none} -> Cache; {ID, Header} -> - array:set(ID - 1, Header, Cache) + array:set(ID - 1, binary:copy(Header), Cache) end end, BlockIdxC0 = lists:foldl(FoldFun, State#state.blockindex_cache, BIC), @@ -1064,7 +1064,9 @@ fetch(LedgerKey, Hash, State, Timings0) -> {Result, Header} = binaryslot_get(SlotBin, LedgerKey, Hash, PressMethod, IdxModDate), BlockIndexCache = - array:set(SlotID - 1, Header, State#state.blockindex_cache), + array:set(SlotID - 1, + binary:copy(Header), + State#state.blockindex_cache), {_SW3, Timings3} = update_timings(SW2, Timings2, noncached_block, false), {Result,