Closed Bug 82370 Opened 24 years ago Closed 24 years ago

nsDiskCacheMap::WriteDiskCacheEntry leaks diskEntry

Categories

(Core :: Networking: Cache, defect)

x86
Linux
defect
Not set
normal

Tracking

()

VERIFIED FIXED
mozilla0.9.1

People

(Reporter: dbaron, Assigned: gordon)

Details

(Keywords: memory-leak, Whiteboard: sr=darin, r=dbaron, a=asa)

Attachments

(2 files)

According to the boehm GC, we leak objects allocated at the following stack: CreateDiskCacheEntry(nsDiskCacheBinding *) nsDiskCacheMap::WriteDiskCacheEntry(nsDiskCacheBinding *) nsDiskCacheDevice::DeactivateEntry(nsCacheEntry *) nsCacheService::DeactivateEntry(nsCacheEntry *) nsCacheService::CloseDescriptor(nsCacheEntryDescriptor *) nsCacheEntryDescriptor::Close(void) nsCacheEntryDescriptor::~nsCacheEntryDescriptor(void) nsCacheEntryDescriptor::Release(void) nsCOMPtr::assign_assuming_AddRef(nsICacheEntryDescriptor *) nsCOMPtr::assign_with_AddRef(nsISupports *) nsCOMPtr::operator=(nsICacheEntryDescriptor *) nsHttpChannel::CloseCacheEntry(unsigned int) It looks to me like the problem is that nsDiskCacheMap::WriteDiskCacheEntry leaks the memory allocated by CreateDiskCacheEntry. Also, it looks like there are some free memory mismatches in this code. Since the memory is allocated with new[], it should be freed with delete[]. It might be a good idea to have static methods on nsDiskCacheEntry for creating and freeing padded entries, or something like that...
This is a pretty serious memory leak and should be fixed for 0.9.1. I'll submit a patch later today.
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla0.9.1
sr=darin
Whiteboard: sr=darin, r=?, a=?
r=dbaron (although I think in the future it would be nice to have a typesafe way of doing this, where you have the casts all in one central pair of methods for allocating and freeing the nsDiskCacheEntry).
Actually, one question: when you call nsCRT::zero, isn't metaSize going to be zero since that's what nsCacheEntry::FlattenMetaData sets it to? Is that what you want?
FlattenMetaData() initializes *size to 0, but then calls PL_DHashTableEnumerate(& table, CalculateSize, size), which sets size to the metadata byte count.
Whiteboard: sr=darin, r=?, a=? → sr=darin, r=dbaron, a=?
Ah, I see. I missed the |return| in the middle of the function. r=dbaron
a=asa on behalf of drivers
Fix checked in.
Status: ASSIGNED → RESOLVED
Closed: 24 years ago
Resolution: --- → FIXED
Whiteboard: sr=darin, r=dbaron, a=? → sr=darin, r=dbaron, a=asa
Checkins confirmed in LXR, the patches show the correct revised file except: nsDiskCacheEntry.cpp, 1.9 is patched, instead of 1.8.
Status: RESOLVED → VERIFIED
QA Contact: tever → cacheqa
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: