diff --git a/data/lib/mailapi/mailslice.js b/data/lib/mailapi/mailslice.js index 0b916fca..c0ce8a54 100755 --- a/data/lib/mailapi/mailslice.js +++ b/data/lib/mailapi/mailslice.js @@ -1427,8 +1427,10 @@ FolderStorage.prototype = { // console.log(' dirty block:', blockInfo.blockId); continue; } - // do not discard blocks that overlap mail slices - if (blockIntersectsAnySlice(blockInfo)) + // If a non-body block, do not discard blocks that overlap mail + // slices. For bodies, want to always purge as front end may + // decide to never shrink a messages slice. + if (blockType !== 'body' && blockIntersectsAnySlice(blockInfo)) continue; // console.log('discarding', blockType, 'block', blockInfo.blockId); delete blockMap[blockInfo.blockId]; @@ -2620,6 +2622,15 @@ FolderStorage.prototype = { doneCallback, progressCallback); }.bind(this); + // The front end may not be calling shrink any more, to reduce + // complexity for virtual scrolling. So be sure to clear caches + // that are not needed, to avoid a large memory growth from + // keeping the header bodies as the user does next/previous + // navigation. + if (this._mutexQueue.length === 0) { + this.flushExcessCachedBlocks('grow'); + } + // --- request messages if (dirMagnitude < 0) { dir = FUTUREWARDS;