Measuring memory usage corrrectly?


I’m just wondering how to correctly measure the memory usage of elements within an electron app.

In the electron app I spawn, two instances of Chrome devtools appear, one for index.html, the other for about.html.

I take a heap snapshot from both of these, which only adds up to around 60MB.

However the total size of the electron process and it’s children, totals around 300MB.

I’m wondering if there are any other ways to measure memory usage from within the electron app, as there would be 240MB unaccounted for. I understand some of this memory would be the chrome browser etc. but I don’t think that would be 240MB?

Any pointers would be much appreciated!


I found out about capturing a trace from startup and using MemoryInfra, from -

I then load the trace into chrome://tracing rather than devtools, which gives me information like below for each of the electron processes:

However a number of times, for the allocated objects, it just says ‘unspecified’ (as you see in the screenshot) is there any way to get the actual objects?

I just found out about a Chrome flag, called memlog, but I’m not sure how to set it to ‘all’ from the command line, I just saw the following to try to set it programmatically -

I’ve tried to enable memlog programmatically now, however I do not seem to be able to obtain the same heap information, as when I record a trace within Chrome itself, using MemoryInfra and the memlog flag.

const { contentTracing } = require('electron')

app.commandLine.appendSwitch('memlog-stack-mode', 'native');

I put the following code, in a ’ on ready ’ function:

    (async () => {
    await contentTracing.startRecording({
      trace_buffer_size_in_kb: 1024*300,
      included_categories: ['disabled-by-default-memory-infra'],
      excluded_categories: ['*'],
      "memory_dump_config": {
      "triggers": [
        { "mode": "light", "periodic_interval_ms": 50 },
        { "mode": "detailed", "periodic_interval_ms": 1000 }
    console.log('Tracing started')
    await new Promise(resolve => setTimeout(resolve, 60000))
    const path = await contentTracing.stopRecording()
    console.log('Tracing data recorded to ' + path)

This does generate a trace, but without any addtional heap information, unlike in Chrome, where I get heap information using the memlog flag.

Any help would be much appreciated! I’m starting to wonder, if electron can’t use the memlog flag for some reason?

I am in Ubuntu and I use an external tool stracer - later corrected to stacer - to monitor resources such as process memory usage. In the dashboard I chose Processes and I can use filter to inspect various running processes such as Electron. This is a cruder picture and I don’t know if this helps. I guess in Windows I would turn to process explorer (from memory from systools library).

Thanks for your reply, I’m also using linux. Do you mean the tool you’re using is called stracer? Have you got a link?

I’ve used a Python API, called psutil to monitor the individual process memory, but I do really need more fine grained data alas.

Sorry, I misnamed the tool in error … here is the link to stacer

and if you are in Linux one easy terminal command to use is htop.

Hi @chrisruk!
I read the same article, but in my trace file is nothing about memory. I described by issue here:
How you got an electron memory trace? Should I forgot any argument?