nsMsgDatabase leaks a mork factory

RESOLVED FIXED

Status

RESOLVED FIXED
12 years ago
10 years ago

People

(Reporter: mscott, Assigned: mscott)

Tracking

({memory-leak})

Trunk
x86
Windows Vista
memory-leak

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(2 attachments)

(Assignee)

Description

12 years ago
the static method: nsMsgDatabase::GetMDBFactory
has a reference to a nsIMdbFactory which never gets released.


http://mxr.mozilla.org/mozilla/source/mailnews/db/msgdb/src/nsMsgDatabase.cpp#976
(Assignee)

Comment 1

12 years ago
I think nsAddrDatabase suffers from the same leak.
(Assignee)

Comment 2

12 years ago
Created attachment 272265 [details] [diff] [review]
[checked in]one way to fix this

This is one way we could fix this leak. nsIMdbFactoryFactory already caches the mork factory for us. See:

NS_IMETHODIMP nsMorkFactoryFactory::GetMdbFactory(nsIMdbFactory **aFactory)
{
  if (!gMDBFactory)
    gMDBFactory = MakeMdbFactory();
  *aFactory = gMDBFactory;
  NS_IF_ADDREF(gMDBFactory);
  return (gMDBFactory) ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
}

So use a nsCOMPtr and let each database object have its own ref to the factory singleton.
Attachment #272265 - Flags: superreview?(bienvenu)

Updated

12 years ago
Attachment #272265 - Flags: superreview?(bienvenu) → superreview+
(Assignee)

Updated

12 years ago
Attachment #272265 - Attachment description: one way to fix this → [checked in]one way to fix this
(Assignee)

Comment 3

12 years ago
Created attachment 272344 [details] [diff] [review]
same fix for the address book data source
Attachment #272344 - Flags: superreview?
(Assignee)

Updated

12 years ago
Attachment #272344 - Flags: superreview? → superreview?(bienvenu)

Updated

12 years ago
Attachment #272344 - Flags: superreview?(bienvenu) → superreview+
(Assignee)

Updated

12 years ago
Status: NEW → RESOLVED
Last Resolved: 12 years ago
Resolution: --- → FIXED

Updated

12 years ago
Keywords: mlk

Updated

12 years ago
Depends on: 388532
Duplicate of this bug: 347678
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.