Welcome to the Linux Foundation Forum!

Chap 14. process.memoryUsage()

Hi,
Explanations of Chap 14 on process.memoryUsage(), suggests heapUsed is the total amount of memory (RAM+ swap), while rss is the amount of RAM. However rss is greater than heapUsed, so I think something must be missing in the explanation...
Can anyone clarify what these really are?
Thank you

Answers

  • djedjedjedje Posts: 20

    Agree with Pablo,

    Running this simple loop the heapUsed grows, but rss don't..... (It would surprise me if the swap area is in use for this case).

     const d = [process.memoryUsage()]
    
    let i = 0
    while(i < 1000) {
        i++
        if(i === 500) d.push(process.memoryUsage())
    }
    d.push(process.memoryUsage())
    
    console.table(d)
    
    

    ┌─────────┬──────────┬───────────┬──────────┬──────────┬──────────────┐
    │ (index) │ rss │ heapTotal │ heapUsed │ external │ arrayBuffers │
    ├─────────┼──────────┼───────────┼──────────┼──────────┼──────────────┤
    │ 0 │ 31649792 │ 4730880 │ 2932488 │ 970568 │ 9402 │
    │ 1 │ 31649792 │ 4730880 │ 2936368 │ 970608 │ 9402 │
    │ 2 │ 31649792 │ 4730880 │ 2936760 │ 970608 │ 9402 │
    └─────────┴──────────┴───────────┴──────────┴──────────┴──────────────┘

Sign In or Register to comment.