MDN may have intermittent access issues April 18 13:00 - April 19 01:00 UTC. See whistlepig.mozilla.org for all notifications.

mozilla

Revision 493249 of Components.utils.getWeakReference

  • Revision slug: Components.utils.getWeakReference
  • Revision title: Components.utils.getWeakReference
  • Revision id: 493249
  • Created:
  • Creator: kscarfone
  • Is current revision? No
  • Comment Replaced Gecko_callout_header macro with a simple note

Revision Content

{{ gecko_minversion_header("1.9") }}

This method was introduced in Firefox 3 and is used for obtaining a weak reference for an object. To obtain the object reference, you have to call get() on the resulting object.

In addition, just because get() succeeds doesn't mean your object is valid. It might simply not have been garbage collected yet. You might have to check other aspects of the object (like {{ domxref("Node.parentNode()") }} on a DOM node) to verify the object is truly what you want.

Syntax

weakRef = Components.utils.getWeakReference(obj);

Parameters

obj
The object for which to obtain a weak reference.

Note: In {{Gecko("11.0")}}, this method was changed to throw an exception if obj is null. In {{Gecko("12.0")}}, the previous behavior of silently failing has been restored.

{{ languages( { "ja": "ja/Components.utils.getWeakReference" } ) }}

Revision Source

<p>{{ gecko_minversion_header("1.9") }}</p>
<p>This method was introduced in <a href="/en/Firefox_3_for_developers" title="en/Firefox_3_for_developers">Firefox 3</a> and is used for obtaining a weak reference for an object. To obtain the object reference, you have to call <code>get()</code> on the resulting object.</p>
<p>In addition, just because <code>get()</code> succeeds doesn't mean your object is valid. It might simply not have been garbage collected yet. You might have to check other aspects of the object (like {{ domxref("Node.parentNode()") }} on a DOM node) to verify the object is truly what you want.</p>
<h3 id="Syntax">Syntax</h3>
<pre>
weakRef = Components.utils.getWeakReference(<em>obj</em>);
</pre>
<h4 id="Parameters">Parameters</h4>
<dl>
 <dt>
  <code>obj</code></dt>
 <dd>
  The object for which to obtain a weak reference.</dd>
</dl>
<div class="note">
 <p><strong>Note:</strong> In {{Gecko("11.0")}}, this method was changed to throw an exception if <code>obj</code> is <code>null</code>. In {{Gecko("12.0")}}, the previous behavior of silently failing has been restored.</p>
</div>
<p>{{ languages( { "ja": "ja/Components.utils.getWeakReference" } ) }}</p>
Revert to this revision