Labs/Jetpack/JEP/28: Difference between revisions

added information about memory metadata objects
(→‎memory: updated)
(added information about memory metadata objects)
Line 102: Line 102:
=== <tt>memory</tt> ===
=== <tt>memory</tt> ===


<tt>memory</tt> is an object that exposes functionality to track objects of interest and help prevent memory leaks.
<tt>memory</tt> is an object that exposes functionality to track objects of interest and help diagnose and prevent memory leaks.


<tt>memory.'''track'''(''object'', [''bin''])</tt>
<tt>memory.'''track'''(''object'', [''bin''])</tt>
Line 110: Line 110:
<tt>memory.'''getObjects'''([''bin''])</tt>
<tt>memory.'''getObjects'''([''bin''])</tt>


Returns an <tt>Array</tt> of all live tracked objects that have been categorized with the given bin name. If ''bin'' isn't provided, all live tracked objects are returned.
Returns an <tt>Array</tt> containing information about tracked objects that have been categorized with the given bin name. If ''bin'' isn't provided, information about all live tracked objects are returned.
 
Each element of the array is an object with the following keys:
 
{|cellpadding="5" cellspacing="0" border="1" width="100%"
|<tt>weakref</tt>
|A weak reference to the object being tracked. Call <tt>get()</tt> on this object to retrieve its strong reference; if a strong reference to the object no longer exists, <tt>get()</tt> will return <tt>null</tt>.
|-
|<tt>created</tt>
|A <tt>Date</tt> representing the date and time that <tt>memory.track()</tt> was called on the object being tracked.
|-
|<tt>filename</tt>
|The name of the file that called <tt>memory.track()</tt> on the object being tracked.
|-
|<tt>lineNo</tt>
|The line number of the file that called <tt>memory.track()</tt> on the object being tracked.
|}


<tt>memory.'''getBins'''()</tt>
<tt>memory.'''getBins'''()</tt>
874

edits