View of the front-end memory in several ways

First, the browser window.performance

 

 Second, node environment using process.memoryUsage ()

// mimic memory recovery 
var size = 20 is 1024 * 1024 *
 var arrall = [] 

function getme () {
     var MEM = process.memoryUsage () 
    the console.log (MEM) 
    var the format = function (bytes) {
         return (bytes / 1024 / 1024) .toFixed (2) + 'MB' ; 
    } 
    the console.log ( 'heapTotal:' + the format (mem.heapTotal) + 'heapUsed:' + the format (mem.heapUsed)) 
} 

getme () 

// V8 engine only memory 1.4g disposal 
for ( var I = 0; I <20 is; I ++ ) {
     IF (arrall.length>. 4) {
        arrall.shift()
    }
    arrall.push(new Array(size))
    getme()
}

Guess you like

Origin www.cnblogs.com/sweet-ice/p/12047622.html