Changes

Jump to: navigation, search

XPCOM Shutdown

2,872 bytes added, 17:25, 14 November 2005
no edit summary
The goal: to cleanly shut down XPCOM components, including component loaders, so that all cross-module references are cleaned up and the component DLLs can be unloaded.

The problems: the current "xpcom-shutdown" notification is not sufficient because component loaders cannot unload until all their loaded components are first unloaded. In addition GC does not happen until very late, while we're in the middle of destroying the component manager.

== Terms ==

; primary module : An XPCOM module which is not a component loader
; root reference : A reference to an XPCOM object in a module, which is not being held as a result of an external XPCOM reference (i.e. a static or module-wide COMPtr, ''not'' member comptrs).

== XPCOM Shutdown Sequence ==

<table border="1">
<tr>
<th>Step
<th>Description
<th>Component Manager
<th>Event Queues

<tr>
<th><tt>xpcom-shutdown</tt> notification
<td>Initial notification of xpcom shutdown... during this observer topic all primary modules should begin shutdown and should release any root references.
<td rowspan="5">All calls allowed
<td rowspan="4">Events accepted

<tr>
<th>Event Processing</th>
<td>All events on the main event queue are processed

<tr>
<th><tt>xpcom-shutdown-threads</tt> notification
<td>Any non-main-thread event queues should be finished by the module which owns them. All threads running XPCOM code should be joined. Any special services that might be required for component loader shutdown should be obtained and cached by the end of this notification. Initial garbage collection should be performed at this stage.

<tr>
<th>Event Processing</th>
<td>All events on the main event queue are processed

<tr>
<th>Eventq shutdown
<td>The main event queue stops accepting events. All remaining events on the main event queue are processed.
<td>No events accepted

<tr>
<th>XPCOM Component Shutdown
<td>The following XPCOM components which hold global references will be shut down: service manager, component manager, observer service. nsIModules are released except for component managers, and all nsIObservers are release except those for which the last two notifications must be given.
<td>No calls allowed.

<tr>
<th><tt>xpcom-shutdown-gc</tt> notification
<td>A final GC should be performed by component loaders. This notification may be repeated if observers indicate GC roots still exist; TODO: how do they indicate this? Any outstanding roots through XPCOM references should be asserted and forcibly invalidated if necessary.

<tr>
<th><tt>xpcom-loader-shutdown</tt> notification
<td>Component loaders (except for the binary/static component loaders) should do their final shutdown/cleanup activities, unloading all modules.

<tr>
<th>Binary component unload
<td>The static and binary component loaders will unload the binary components

</table>
Confirm, emeritus
1,217
edits

Navigation menu