Open Bug 1689863 Opened 4 years ago Updated 7 months ago

Huge memory usage of zone / strings on main process with multi-process browser toolbox open

Categories

(DevTools :: General, defect, P3)

defect

Tracking

(Not tracked)

People

(Reporter: whimboo, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: memory-footprint)

Attachments

(1 file, 1 obsolete file)

Attached file memory-report.json.gz

Mozilla/5.0 (Macintosh; Intel Mac OS X 10.16; rv:87.0) Gecko/20100101 Firefox/87.0 ID:20210127093943

In a test profile that is open for a while and I'm using to test a temporary webextension I had a couple of tabs open. Then I noticed a quite large memory usage of the main process (~1.3GB). As such I triggered a memory report (find it as attached). A lot of the memory is actually part of the zone / strings section. Closing all tabs and triggering a minimize memory action doesn't change anything. The strings as used by some websites stay around and accumulate the main process' memory. Interestingly the memory usage even grows by measuring memory via about:memory, which means it's now at 2GB.

The high memory use for window(chrome://browser/content/webext-panels.xhtml) might warrant a fix in my webextension, which doesn't handle unloading yet. But none of the strings are mentioned above seem to be related to the web extension.

Andrew, do you have an idea?

Flags: needinfo?(continuation)

Here an excerpt of the zone / strings:

Main Process (pid 54927)
Explicit Allocations

2,034.63 MB (100.0%) -- explicit
├────818.29 MB (40.22%) -- js-non-window
│    ├──788.47 MB (38.75%) -- zones
│    │  ├──774.45 MB (38.06%) -- zone(0x10e37c000)
│    │  │  ├──457.33 MB (22.48%) -- strings
│    │  │  │  ├──436.31 MB (21.44%) -- (944 tiny)
│    │  │  │  │  ├───16.00 MB (00.79%) ++ string(length=1215037, copies=4, "!function(e){function t(t){for(var n,o,a=t[0],i=t[1],s=0,l=[];s<a.length;s++)o=a[s],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&l.push(r[o][0]),r[o]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(u&&u(t);l.length;)l.shift()()}var n={},r={0:0};var o={};var a={273:function(){return{}}};function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var s=new Promise((function(t,o){n=r[e]=[t,o]}));t.push(n[2]=s);var l,c=document.createElement("script");c.charset="utf-8",c.timeout=120,i.nc&&c.setAttribute("nonce",i.nc),c.src=function(e){return i.p+""+e+".820a88dfe935a6797ae9.bundle.js"}(e);var u=new Error;l=function(t){c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(0!==n){if(n){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.//n("+o+": "+a+")",u.name="ChunkLoadError",u.type=o,u.reque" (truncated))
│    │  │  │  │  ├────8.00 MB (00.39%) ++ string(length=1048576, copies=8, "!function(e){function t(t){for(var n,o,a=t[0],i=t[1],s=0,l=[];s<a.length;s++)o=a[s],Object.prototype.hasOwnProperty.call(r,o)&&r[o]&&l.push(r[o][0]),r[o]=0;for(n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n]);for(u&&u(t);l.length;)l.shift()()}var n={},r={0:0};var o={};var a={273:function(){return{}}};function i(t){if(n[t])return n[t].exports;var r=n[t]={i:t,l:!1,exports:{}};return e[t].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.e=function(e){var t=[],n=r[e];if(0!==n)if(n)t.push(n[2]);else{var s=new Promise((function(t,o){n=r[e]=[t,o]}));t.push(n[2]=s);var l,c=document.createElement("script");c.charset="utf-8",c.timeout=120,i.nc&&c.setAttribute("nonce",i.nc),c.src=function(e){return i.p+""+e+".820a88dfe935a6797ae9.bundle.js"}(e);var u=new Error;l=function(t){c.onerror=c.onload=null,clearTimeout(d);var n=r[e];if(0!==n){if(n){var o=t&&("load"===t.type?"missing":t.type),a=t&&t.target&&t.target.src;u.message="Loading chunk "+e+" failed.//n("+o+": "+a+")",u.name="ChunkLoadError",u.type=o,u.reque" (truncated))
│    │  │  │  │  ├────4.22 MB (00.21%) ++ string(length=733900, copies=6, "AGFzbQEAAAABbhFgA39/fwF/YAJ/fwF/YAF/AX9gAn9/AGADf39/AGABfwBgAABgBH9/f38Bf2AAAX9gBH9/f38AYAV/f39/fwBgBX9/f39/AX9gBn9/f39/fwBgB39/f39/f38AYAZ/f39/f38Bf2ABfwF+YAAAA7EDrwMAAAAABAcBBAcCBgAFAAABAAEAAAAAAAAAAAAAAAEDAwMGAQEAAAAABAQAAgABAwICAgEAAAEAAAcGAgACAAAAAgACAgICAgIAAAACAgICAgICAgICAgICAgICAQUGBQUFBQUFBQUFBQUGBQAIAgMFAQMFCQMBBQMDBAQJAwMEAwUFAwMFBQMDBQMFBAQEBAEFAwQEAQoBBAEBBAQEBQkABAMDAwMBBAMEAwEDAwMDAQIBCwEDAwEABQUFAQEBAAUBAAEAAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBAQEBBAkJCQUFCQUJCgAJCgUBBQUFBQoFCQkFCgMMBQwFCQUNCgkMBQkJBQkFCQkFDAoKCQUJCQkMAwkDAwQEAwQEAwQEAwQEAQEBAQEBAQEBAQEBAQEAAQEBBQUFAwMEAwUBBQEBAQEBAQEOAQEDAwMGBQIFAwMPAQEBAQEBAQEFAwEGAQABAQEBAQ8BAQECAQEJCgABAQABAQEBAQEBAQAEBQUBBQUFBQUBBQUFBQAAEAQHAXAB3QHdAQUDAQARBgkBfwFBgIDAAAsHGwYBZQIAAWIAbAFjAG0BYQBuAWQAngMBZgCuAwn8AgEAQQEL3AEGjgMdMg+OAjUiLXCKA4sDlAGlAbEBjwGWAZgBmQGzAeYCgQONA3WhA6cDXr8CwALBAs0C4ALCAsMCxALMAbkCugK7AscCX7wCvQK+AswCYgtEVVBZAM4BZg5DUjpXDfkBaiZLJfcBO0I8TVozyQJcSUVRT1Y3xQJoSkHGAj80ygJIR1RMWCTIAj5GU05APcsCnQO" (truncated))
│    │  │  │  │  ├────4.00 MB (00.20%) ++ string(length=331866, copies=6, "// zee.js: zlib compiled to js/n/nvar Zee = (function() {/n/nfunction adjustedTotalMemory(targetVal,stackSize){var totalMemory=64*1024;while(totalMemory<targetVal||totalMemory<2*stackSize){if(totalMemory<16*1024*1024){totalMemory*=2}else{totalMemory+=16*1024*1024}}return totalMemory}function createGzModule(heapMemorySize){var Module={noExitRuntime:true,noImageDecoding:true,TOTAL_STACK:262144,TOTAL_MEMORY:adjustedTotalMemory(heapMemorySize,262144)};var Module;if(!Module)Module=(typeof Module!=="undefined"?Module:null)||{};var moduleOverrides={};for(var key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}var ENVIRONMENT_IS_WEB=typeof window==="object";var ENVIRONMENT_IS_WORKER=typeof importScripts==="function";var ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;var ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){if(!Module["print"])Module["print"]=fu" (truncated))
│    │  │  │  │  ├────4.00 MB (00.20%) ++ string(length=579147, copies=2, "<!DOCTYPE html>/n<html class="ima-sdk-frame">/n  <head>/n    <title></title>/n    <style type="text/css">.videoAdUiActionCta{position:absolute;bottom:30px;box-sizing:border-box;padding:5px;max-width:75%}.uac-android-on-3p-instream.videoAdUiActionCta,.uac-ios-on-3p-instream.videoAdUiActionCta{background:linear-gradient(to top,rgba(0,0,0,0),rgba(0,0,0,.4) 100%);bottom:unset;max-width:100%;padding:12px;top:0;width:100%}.newProgressBarVariant .videoAdUiActionCta{bottom:46px}.videoAdUiActionCtaInset{font-family:arial,sans-serif;font-weight:500;font-size:16px;background:white;display:flex;flex-direction:row;border-radius:8px;box-shadow:0 1px 3px rgba(60,64,67,0.5);overflow:hidden;height:50px;pointer-events:auto}.uac-android-on-3p-instream .videoAdUiActionCtaInset,.uac-ios-on-3p-instream .videoAdUiActionCtaInset{background:transparent;box-shadow:none}.videoAdUiActionCtaIconContainer{min-width:50px;z-index:1000}.uac-android-on-3p-instream .videoAdUiActionCtaIconContainer,.uac-ios-on-3p-instream .videoAdUiActionCtaIc" (truncated))
│    │  │  │  │  ├────3.38 MB (00.17%) ++ string(length=7092, copies=432, "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUM5RENDQW51Z0F3SUJBZ0lJRmxvM2F5bjJIMWt3Q2dZSUtvWkl6ajBFQXdNd2dhTXhDekFKQmdOVkJBWVQKQWxWVE1Sd3dHZ1lEVlFRS0V4Tk5iM3BwYkd4aElFTnZjbkJ2Y21GMGFXOXVNUzh3TFFZRFZRUUxFeVpOYjNwcApiR3hoSUVGTlR5QlFjbTlrZFdOMGFXOXVJRk5wWjI1cGJtY2dVMlZ5ZG1salpURkZNRU1HQTFVRUF3dzhRMjl1CmRHVnVkQ0JUYVdkdWFXNW5JRWx1ZEdWeWJXVmthV0YwWlM5bGJXRnBiRUZrWkhKbGMzTTlabTk0YzJWalFHMXYKZW1sc2JHRXVZMjl0TUI0WERUSXdNVEl4TlRJeE5EVTFNRm9YRFRJeE1ETXdOVEl4TkRVMU1Gb3dnYUl4Q3pBSgpCZ05WQkFZVEFsVlRNUk13RVFZRFZRUUlFd3BEWVd4cFptOXlibWxoTVJZd0ZBWURWUVFIRXcxTmIzVnVkR0ZwCmJpQldhV1YzTVJ3d0dnWURWUVFLRXhOTmIzcHBiR3hoSUVOdmNuQnZjbUYwYVc5dU1SY3dGUVlEVlFRTEV3NUQKYkc5MVpDQlRaWEoyYVdObGN6RXZNQzBHQTFVRUF4TW1ibTl5YldGdVpIa3VZMjl1ZEdWdWRDMXphV2R1WVhSMQpjbVV1Ylc5NmFXeHNZUzV2Y21jd2RqQVFCZ2NxaGtqT1BRSUJCZ1VyZ1FRQUlnTmlBQVJPYlNzNFIrMnNUcTJjCkQzZzdZUlczWFhXRHJpc1NYWjFhODJuMjJxSXQ4TWlPOTlwMzRlOE5FS3E0S0ZlUGExeTNiZVBxQ3J2RkJsK3cKZ1dKTVBGckU2WWpLeFFrQUdJQUdsVCtVS0lPWlhacEF2c0lCalNiY2ZQS3JvREZEcUNlamV6QjVNQTRHQTFVZApEd0VCL3dRRUF3SUhnREFUQmdOVkhTVUV" (truncated))
│    │  │  │  │  ├────3.00 MB (00.15%) ++ string(length=285054, copies=3, "/*! aniview version '6.1.2+25'/nAll rights reserved to ANIVIEW LTD 2021 *//n!function(){var t,e,n={676:function(t,e,n){"use strict";function i(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=new Array(e);n<e;n++)i[n]=t[n];return i}n.d(e,{Z:function(){return i}})},9968:function(t,e,n){"use strict";function i(t){if(Array.isArray(t))return t}n.d(e,{Z:function(){return i}})},6156:function(t,e,n){"use strict";function i(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}n.d(e,{Z:function(){return i}})},692:function(t,e,n){"use strict";function i(t,e){if("undefined"!=typeof Symbol&&Symbol.iterator in Object(t)){var n=[],i=!0,r=!1,o=void 0;try{for(var a,s=t[Symbol.iterator]();!(i=(a=s.next()).done)&&(n.push(a.value),!e||n.length!==e);i=!0);}catch(t){r=!0,o=t}finally{try{i||null==s.return||s.return()}finally{if(r)throw o}}return n}}n.d(e,{Z:function(){return i}})},8970:function(t,e,n){"use strict";function i(){throw new TypeError("Invalid attempt to de" (truncated))
│    │  │  │  │  ├────3.00 MB (00.15%) ++ string(length=330500, copies=3, "/* prebid.js v3.22.0-pre/nUpdated : 2020-11-16 *//n!function(u){var s=window.pbjsChunk;window.pbjsChunk=function(e,t,n){for(var r,o,i,a=0,c=[];a<e.length;a++)o=e[a],d[o]&&c.push(d[o][0]),d[o]=0;for(r in t)Object.prototype.hasOwnProperty.call(t,r)&&(u[r]=t[r]);for(s&&s(e,t,n);c.length;)c.shift()();if(n)for(a=0;a<n.length;a++)i=f(f.s=n[a]);return i};var n={},d={306:0};function f(e){if(n[e])return n[e].exports;var t=n[e]={i:e,l:!1,exports:{}};return u[e].call(t.exports,t,t.exports,f),t.l=!0,t.exports}f.m=u,f.c=n,f.d=function(e,t,n){f.o(e,t)||Object.defineProperty(e,t,{configurable:!1,enumerable:!0,get:n})},f.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return f.d(t,"a",t),t},f.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},f.p="",f.oe=function(e){throw console.error(e),e},f(f.s=817)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),n.d(t,"internal",function(){return k}),n.d(t,"bind",function(){return N}),t.getUniqueIdentif" (truncated))

That's odd. I'm not sure what kind of code would cause those strings to hang around. Are you doing anything with devtools? That can cause weird leakiness.

Short of that, the steps here would be to get a GC log for the main process, grep it to find the address of one of those strings (because the GC log contains part of the value of the string), then run find_roots.py on the GC log to see what is holding the string alive.

Flags: needinfo?(continuation)

(In reply to Andrew McCreight [:mccr8] from comment #2)

That's odd. I'm not sure what kind of code would cause those strings to hang around. Are you doing anything with devtools? That can cause weird leakiness.

Hm, for the given Firefox process I have a browser toolbox open. But that runs in it's own instance. Nevertheless it could mean that the devtools server code as run in the Firefox process leaks memory? Is that a known problem? Nicholas or Alexandre?

Short of that, the steps here would be to get a GC log for the main process, grep it to find the address of one of those strings (because the GC log contains part of the value of the string), then run find_roots.py on the GC log to see what is holding the string alive.

I can have a look at this tomorrow. Looks like it will take a bit of time to get some results:
https://developer.mozilla.org/en-US/docs/Mozilla/Performance/GC_and_CC_logs#Analyzing_GC_and_CC_logs

Flags: needinfo?(poirot.alex)
Flags: needinfo?(nchevobbe)

I closed the browser toolbox and indeed all the extra memory as mentioned above gets cleaned-up when minimizing the memory. So it's clearly a memory footprint issue with devtools.

Component: JavaScript Engine → General
Product: Core → DevTools
Summary: 500MB (22%) memory usage of zone / strings usage on main process → 500MB (22%) memory usage of zone / strings usage on main process with browser toolbox open

(In reply to Henrik Skupin (:whimboo) [⌚️UTC+2] (away 01/15 - 01/31) from comment #3)

Hm, for the given Firefox process I have a browser toolbox open.

To be clear this is about the new multi-process browser toolbox.

Summary: 500MB (22%) memory usage of zone / strings usage on main process with browser toolbox open → 500MB (22%) memory usage of zone / strings usage on main process with multi-process browser toolbox open

Note that cleaning the console from all messages doesn't help. The string instances still stay around also after an additional GC.

This is actually pretty easy to reproduce. Here are the steps:

  1. Start Firefox and open the multi-process browser toolbox
  2. Open about:memory in a tab and create an initial measurement
  3. Open several tabs and start navigating through various pages across these tabs
  4. Switch back to about:memory and create another measurement

After step 4 you will see that zones / strings has been grown, and contains strings from web pages that are no longer open. Continue to navigate if needed to see that it infinitely grows. The only chance to get rid of all these strings is to actually close the multi-process browser toolbox.

I actually won't find the time to do any GC analysis. Maybe someone else working on devtools can actually do that, or even knows what might go wrong here.

Summary: 500MB (22%) memory usage of zone / strings usage on main process with multi-process browser toolbox open → Huge memory usage of zone / strings on main process with multi-process browser toolbox open

Also tentatively blocking the MBT enabling bug. Leaks are a potential cause for the overall slowness related to MBT.

Blocks: 1625937
Severity: -- → S3
Priority: -- → P3

Not sure what's going on, but the strings that are leaking look like sources and sourcemaps.
On the MBT, I don't know when/if we clear the sources actor. I would guess when the associated target is destroyed, but it would be nice to check what we're doing about that.

Flags: needinfo?(nchevobbe)

Memory usage of browser console and toolbox should have been drastically improved, especially when running in parent-process only and/or with keeping network inspection off by default.

Flags: needinfo?(poirot.alex)

I think that I saw that again as part of bug 842979 comment 21. I'll keep an eye open for that particular issue.

Attachment #9383765 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: