B2G/gecko/toolkit/components/aboutmemory/content/aboutMemory.js
/**
 * Processes reports (whether from reporters or from a file) and append the
 * main part of the page.
 *
 * @param aBody
 *        The DOM body element.
 * @param aProcess
 *        Function that extracts the memory reports from the reporters or from
 *        file.
 * @param aHasMozMallocUsableSize
 *        Boolean indicating if moz_malloc_usable_size works.
 * @param aForceShowSmaps
 *        True if we should show the smaps memory reporters even if we're not
 *        in verbose mode.
 */
Processes reports (whether from reporters or from a file) and append the
main part of the page.

@param aBody
The DOM body element.
@param aProcess
Function that extracts the memory reports from the reporters or from
file.
@param aHasMozMallocUsableSize
Boolean indicating if moz_malloc_usable_size works.
@param aForceShowSmaps
True if we should show the smaps memory reporters even if we're not
in verbose mode.
Processes reports ( whether from reporters or from a file ) and append the main part of the page . @param aBody The DOM body element . @param aProcess Function that extracts the memory reports from the reporters or from file . @param aHasMozMallocUsableSize Boolean indicating if moz_malloc_usable_size works . @param aForceShowSmaps True if we should show the smaps memory reporters even if we ' re not in verbose mode .
function appendAboutMemoryMain(aBody, aProcess, aHasMozMallocUsableSize,
                               aForceShowSmaps)
{
  let treesByProcess = {}, degeneratesByProcess = {}, heapTotalByProcess = {};
  getTreesByProcess(aProcess, treesByProcess, degeneratesByProcess,
                    heapTotalByProcess, aForceShowSmaps);
  let processes = Object.keys(treesByProcess);
  processes.sort(function(a, b) {
    assert(a != b, "Elements of Object.keys() should be unique, but " +
                   "saw duplicate " + a + " elem.");
    if (a == gUnnamedProcessStr) {
      return -1;
    }
    if (b == gUnnamedProcessStr) {
      return 1;
    }
    let nodeA = degeneratesByProcess[a]['resident'];
    let nodeB = degeneratesByProcess[b]['resident'];
    if (nodeA && nodeB) {
      return TreeNode.compareAmounts(nodeA, nodeB);
    }
    if (nodeA) {
      return -1;
    }
    if (nodeB) {
      return 1;
    }
    return 0;
  });
  for (let i = 0; i < processes.length; i++) {
    let process = processes[i];
    let section = appendElement(aBody, 'div', 'section');
    appendProcessAboutMemoryElements(section, process,
                                     treesByProcess[process],
                                     degeneratesByProcess[process],
                                     heapTotalByProcess[process],
                                     aHasMozMallocUsableSize);
  }
}
function appendAboutMemoryMain ( aBody , aProcess , aHasMozMallocUsableSize , aForceShowSmaps ) { let treesByProcess = { } , degeneratesByProcess = { } , heapTotalByProcess = { } ; getTreesByProcess ( aProcess , treesByProcess , degeneratesByProcess , heapTotalByProcess , aForceShowSmaps ) ; let processes = Object . keys ( treesByProcess ) ; processes . sort ( function ( a , b ) { assert ( a != b , "Elements of Object.keys() should be unique, but " + "saw duplicate " + a + " elem." ) ; if ( a == gUnnamedProcessStr ) { return - 1 ; } if ( b == gUnnamedProcessStr ) { return 1 ; } let nodeA = degeneratesByProcess [ a ] [ 'resident' ] ; let nodeB = degeneratesByProcess [ b ] [ 'resident' ] ; if ( nodeA && nodeB ) { return TreeNode . compareAmounts ( nodeA , nodeB ) ; } if ( nodeA ) { return - 1 ; } if ( nodeB ) { return 1 ; } return 0 ; } ) ; for ( let i = 0 ; i < processes . length ; i ++ ) { let process = processes [ i ] ; let section = appendElement ( aBody , 'div' , 'section' ) ; appendProcessAboutMemoryElements ( section , process , treesByProcess [ process ] , degeneratesByProcess [ process ] , heapTotalByProcess [ process ] , aHasMozMallocUsableSize ) ; } }
Processes reports (whether from reporters or from a file) and append the
 main part of the page.
Processes reports ( whether from reporters or from a file ) and append the main part of the page .
// Sort our list of processes.  Always start with the main process, then sort // by resident size (descending).  Processes with no resident reporter go at // the end of the list. // Generate output for each process.