Closed Bug 559400 Opened 14 years ago Closed 14 years ago

modal dialogs during startup cause cocoa object leaks

Categories

(Core :: Widget: Cocoa, defect)

x86
macOS
defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jfkthame, Assigned: jfkthame)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

When the Add-ons Compatibility checking dialog or the Profile Manager UI is displayed during startup, we call nsCocoaWindow::SetModal while setting up the window. This happens outside the event loop, so our main autorelease pool is not in place, and therefore when cocoa internally uses autorelease, it will leak objects to the root pool (which we are trying to get rid of).

From a run with the

Reading symbols for shared libraries . done
WARNING: NS_ENSURE_TRUE(compMgr) failed: file nsComponentManagerUtils.cpp, line 90
<....snip....>
WARNING: dependent window created without a parent: file /Users/jonathan/mozdev/mozilla-central/toolkit/components/startup/src/nsAppStartup.cpp, line 456
++DOCSHELL 0x1166d5e70 == 1
++DOMWINDOW == 1 (0x11a0050d8) [serial = 1] [outer = 0x0]
++DOMWINDOW == 2 (0x117011c98) [serial = 2] [outer = 0x11a005080]
2010-04-14 19:46:25.524 firefox-bin[46501:a0f] *** __NSAutoreleaseNoPool(): Object 0x11ef1f670 of class NSRunningApplication autoreleased with no pool in place - just leaking

The attached patch adds a local autorelease pool in SetModal to fix this.
Attachment #439049 - Flags: review?(joshmoz)
Oops, that should have read "From a run with the -P option, to display the profile manager. The same leak occurs when upgrading from an older version, causing the Add-ons dialog to appear."
Comment on attachment 439049 [details] [diff] [review]
add local autorelease pool in nsCocoaWindow::SetModal, for startup dialogs

Looks good but please fix this comment:

+  // therefore, it needs to provide an autorelease pool to avoid cocoa
+  // object leakage messages.

We're not trying to avoid leak *messages*, we're trying to avoid *leaks*.

Thanks!
Attachment #439049 - Flags: review?(joshmoz) → review+
Pushed http://hg.mozilla.org/mozilla-central/rev/8df1936a0f3d (with edited comment).
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: