Closed Bug 388101 Opened 17 years ago Closed 17 years ago

nsMsgDatabase leaks a mork factory

Categories

(MailNews Core :: Database, defect)

x86
Windows Vista
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: mscott, Assigned: mscott)

References

Details

(Keywords: memory-leak)

Attachments

(2 files)

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
I think nsAddrDatabase suffers from the same leak.
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)
Attachment #272265 - Flags: superreview?(bienvenu) → superreview+
Attachment #272265 - Attachment description: one way to fix this → [checked in]one way to fix this
Attachment #272344 - Flags: superreview?
Attachment #272344 - Flags: superreview? → superreview?(bienvenu)
Attachment #272344 - Flags: superreview?(bienvenu) → superreview+
Status: NEW → RESOLVED
Closed: 17 years ago
Resolution: --- → FIXED
Keywords: mlk
Depends on: 388532
Product: Core → MailNews Core
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: