зеркало из https://github.com/mozilla/pjs.git
fix for bug 91795 "large downloads cause mozilla to consume too much memory".
Changed OnDataSizeChange() to abort when entry size exceeds cache capacity. r=dougt, sr=darin.
This commit is contained in:
Родитель
8345ac1cb7
Коммит
99fe8f3daf
|
@ -631,8 +631,15 @@ nsDiskCacheDevice::OnDataSizeChange(nsCacheEntry * entry, PRInt32 deltaSize)
|
|||
|
||||
NS_ASSERTION(binding->mRecord.ValidRecord(), "bad record");
|
||||
|
||||
PRUint32 newSize = entry->DataSize() + deltaSize;
|
||||
if (newSize > mCacheCapacity) {
|
||||
nsresult rv = nsCacheService::GlobalInstance()->DoomEntry_Locked(entry);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"DoomEntry_Locked() failed.");
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
|
||||
PRUint32 sizeK = ((entry->DataSize() + 0x0399) >> 10); // round up to next 1k
|
||||
PRUint32 newSizeK = ((entry->DataSize() + deltaSize + 0x399) >> 10);
|
||||
PRUint32 newSizeK = ((newSize + 0x399) >> 10);
|
||||
|
||||
NS_ASSERTION((sizeK < USHRT_MAX) && (sizeK == binding->mRecord.DataFileSize()),
|
||||
"data size out of sync");
|
||||
|
|
|
@ -250,6 +250,12 @@ nsMemoryCacheDevice::OnDataSizeChange( nsCacheEntry * entry, PRInt32 deltaSize)
|
|||
{
|
||||
if (entry->IsStreamData()) {
|
||||
// we have the right to refuse or pre-evict
|
||||
PRUint32 newSize = entry->DataSize() + deltaSize;
|
||||
if (newSize > mSoftLimit) {
|
||||
nsresult rv = nsCacheService::GlobalInstance()->DoomEntry_Locked(entry);
|
||||
NS_ASSERTION(NS_SUCCEEDED(rv),"DoomEntry_Locked() failed.");
|
||||
return NS_ERROR_ABORT;
|
||||
}
|
||||
}
|
||||
|
||||
// adjust our totals
|
||||
|
|
Загрузка…
Ссылка в новой задаче