I'm doing some memory profiling in my electron app and running with the --enable-precise-memory-info flag and I see there are two ways to get information on current memory allocation: Nodes process.memoryUsage() and Chromes performance.memory. Here are the values returned from each call:
// process.memoryUsage()
{
"rss": 631332864, // ~ 602.09 MB
"heapTotal": 97619968, // ~ 93.10 MB
"heapUsed": 91908280, // ~ 87.65 MB
"external": 83524574 // ~ 79.66 MB
}
// performance.memory
{
"totalJSHeapSize": 177817582, // ~ 169.58 MB
"jsHeapSizeLimit": 1107296256, // 1056 MB
"usedJSHeapSize": 175333878 // ~ 167.21 MB
}
As you can see the values vary pretty significantly but I would expect both totalJSHeapSize and usedJSHeapSize from performance.memory to be the same as heapTotal and heapUsed. Why are they different? Is one considered more accurate? Do they mean something different from each other?
For some more context I'm running both commands in the dev tools of the electron browser window and opening the browser window with the following options:
{
// ...
webPreferences: {
nodeIntegration: true,
backgroundThrottling: false,
}
}
Thank you!