Skip to content

Commit

Permalink
clear body block caches on grow requests
Browse files Browse the repository at this point in the history
  • Loading branch information
jrburke committed Apr 9, 2014
1 parent 4bc27cf commit 0689272
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions data/lib/mailapi/mailslice.js
Expand Up @@ -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];
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0689272

Please sign in to comment.