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:
gordon%netscape.com 2002-05-10 23:44:53 +00:00
Родитель 8345ac1cb7
Коммит 99fe8f3daf
2 изменённых файлов: 14 добавлений и 1 удалений

9
netwerk/cache/src/nsDiskCacheDevice.cpp поставляемый
Просмотреть файл

@ -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");

6
netwerk/cache/src/nsMemoryCacheDevice.cpp поставляемый
Просмотреть файл

@ -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