Closed Bug 1241271 Opened 8 years ago Closed 8 years ago

Ghost windows with emunittest 0.5 suite

Categories

(Core :: DOM: Core & HTML, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jujjyl, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [MemShrink:P1])

Attachments

(4 files)

I am trying to find memory leaks with DMD and in order to do so, I need to close the tabs I have been running, and make sure everything is garbage collected so that outstanding live allocations are released and do not confuse DMD. However Firefox is clinging on to the pages even though they have been closed.

STR:
1. Run emunittest 0.5 suite in full
2. After the suite finishes, close all tabs except a single new opened tab
3. Open about:memory and tap through GC/CC/Minimize memory usage buttons in the Free memory panel.

Expected: Step 3 should force the closed pages to be reclaimed and all memory should be freed.

Observed: Firefox is consuming 17GB of memory with about:memory showing

17,255.52 MB (100.0%) -- explicit
├──14,623.95 MB (84.75%) -- window-objects
│  ├──14,611.29 MB (84.68%) -- top(none)/detached
│  │  ├──10,609.35 MB (61.48%) -- window(file:///D:/code/emgames/emunittests/2015-09-29-emunittest_0.4-Teleporter-u5.2.1p1_hg-e.1.34.11-release-prof/index.html?playback&novsync)
│  │  │  ├──10,608.94 MB (61.48%) -- js-compartment(file:///D:/code/emgames/emunittests/index.html, about:blank)
│  │  │  │  ├──10,607.28 MB (61.47%) -- classes
│  │  │  │  │  ├──10,421.39 MB (60.39%) ++ class(ArrayBuffer)
│  │  │  │  │  ├─────178.20 MB (01.03%) -- class(WasmModuleObject)
│  │  │  │  │  │     ├──178.20 MB (01.03%) ++ objects
│  │  │  │  │  │     └────0.00 MB (00.00%) ++ shapes/gc-heap
│  │  │  │  │  └───────7.69 MB (00.04%) ++ (10 tiny)
│  │  │  │  └───────1.66 MB (00.01%) ++ (5 tiny)
│  │  │  └───────0.41 MB (00.00%) ++ (3 tiny)
│  │  ├───2,025.64 MB (11.74%) -- window(file:///D:/code/emgames/emunittests/2015-09-01-emunittest_0.4-SurvivalShooter-u5.1.3f1_hg-e1.34.6-release-prof/index.html?playback&novsync)
│  │  │   ├──2,025.27 MB (11.74%) -- js-compartment(file:///D:/code/emgames/emunittests/index.html, about:blank)
│  │  │   │  ├──2,024.13 MB (11.73%) -- classes
│  │  │   │  │  ├──1,813.75 MB (10.51%) -- class(ArrayBuffer)
│  │  │   │  │  │  ├──1,813.75 MB (10.51%) -- objects
│  │  │   │  │  │  │  ├──1,280.00 MB (07.42%) ── non-heap/elements/asm.js [5]
│  │  │   │  │  │  │  ├────533.75 MB (03.09%) ── malloc-heap/elements/non-asm.js [5]
│  │  │   │  │  │  │  └──────0.00 MB (00.00%) ── gc-heap [5]
│  │  │   │  │  │  └──────0.00 MB (00.00%) ++ shapes/gc-heap
│  │  │   │  │  ├────204.86 MB (01.19%) -- class(WasmModuleObject)
│  │  │   │  │  │    ├──204.86 MB (01.19%) ++ objects
│  │  │   │  │  │    └────0.00 MB (00.00%) ++ shapes/gc-heap
│  │  │   │  │  └──────5.52 MB (00.03%) ++ (8 tiny)
│  │  │   │  └──────1.14 MB (00.01%) ++ (5 tiny)
│  │  │   └──────0.37 MB (00.00%) ++ (3 tiny)
│  │  ├───1,976.29 MB (11.45%) -- window(file:///D:/code/emgames/emunittests/2015-08-29-emunittest_0.4-Stealth-u5.1.3f1_hg-e1.34.6-release-prof/index.html?playback&novsync)
│  │  │   ├──1,975.91 MB (11.45%) -- js-compartment(file:///D:/code/emgames/emunittests/index.html, about:blank)
│  │  │   │  ├──1,974.48 MB (11.44%) -- classes
│  │  │   │  │  ├──1,772.01 MB (10.27%) -- class(ArrayBuffer)
│  │  │   │  │  │  ├──1,772.01 MB (10.27%) -- objects
│  │  │   │  │  │  │  ├──1,280.00 MB (07.42%) ── non-heap/elements/asm.js [5]
│  │  │   │  │  │  │  ├────492.01 MB (02.85%) ── malloc-heap/elements/non-asm.js [5]
│  │  │   │  │  │  │  └──────0.00 MB (00.00%) ── gc-heap [5]
│  │  │   │  │  │  └──────0.00 MB (00.00%) ++ shapes/gc-heap
│  │  │   │  │  ├────195.26 MB (01.13%) -- class(WasmModuleObject)
│  │  │   │  │  │    ├──195.26 MB (01.13%) ++ objects
│  │  │   │  │  │    └────0.00 MB (00.00%) ++ shapes/gc-heap
│  │  │   │  │  └──────7.20 MB (00.04%) ++ (10 tiny)
│  │  │   │  └──────1.44 MB (00.01%) ++ (5 tiny)
│  │  │   └──────0.37 MB (00.00%) ++ (3 tiny)
│  │  └───────0.01 MB (00.00%) ── window(file:///D:/code/emgames/emunittests/index.html)/dom/other [15]
│  └──────12.67 MB (00.07%) ++ (6 tiny)
├───1,467.15 MB (08.50%) ── heap-unclassified
├───1,005.94 MB (05.83%) -- js-non-window
│   ├────964.35 MB (05.59%) -- runtime
│   │    ├──954.26 MB (05.53%) -- script-sources
│   │    │  ├──346.97 MB (02.01%) -- source(scripts=5, file:///D:/code/emgames/emunittests/2015-09-01-emunittest_0.4-SurvivalShooter-u5.1.3f1_hg-e1.34.6-release-prof/Release/2015-09-01-emunittest_0.4-SurvivalShooter-u5.1.3f1_hg-e1.34.6-release-prof.js)
│   │    │  │  ├──346.97 MB (02.01%) ── uncompressed
│   │    │  │  └────0.00 MB (00.00%) ── misc
│   │    │  ├──333.03 MB (01.93%) -- source(scripts=5, file:///D:/code/emgames/emunittests/2015-08-29-emunittest_0.4-Stealth-u5.1.3f1_hg-e1.34.6-release-prof/Release/2015-08-29-emunittest_0.4-Stealth-u5.1.3f1_hg-e1.34.6-release-prof.js)
│   │    │  │  ├──333.03 MB (01.93%) ── uncompressed
│   │    │  │  └────0.00 MB (00.00%) ── misc
│   │    │  ├──273.34 MB (01.58%) -- source(scripts=5, file:///D:/code/emgames/emunittests/2015-09-29-emunittest_0.4-Teleporter-u5.2.1p1_hg-e.1.34.11-release-prof/Release/2015-09-29-emunittest_0.4-Teleporter-u5.2.1p1_hg-e.1.34.11-release-prof.js)
│   │    │  │  ├──273.34 MB (01.58%) ── uncompressed
│   │    │  │  └────0.00 MB (00.00%) ── misc
│   │    │  └────0.92 MB (00.01%) ++ (20 tiny)
│   │    └───10.09 MB (00.06%) ++ (12 tiny)
│   └─────41.58 MB (00.24%) ++ (2 tiny)
└─────158.47 MB (00.92%) ++ (26 tiny)

which I can't get Firefox to reclaim. The pages should not be in history/back button stack, since the tab that was executing them has been closed a long time ago.

Is there a tool to debug why these pages are not being freed?
Is this emunittest just run as a regular content webpage?

> Is there a tool to debug why these pages are not being freed?

The first step is to look at a cycle collector log to find out what is keeping the the window alive. Though before doing that, it would be good to see if you can minimize the test case a little. 17GB of heap is going to produce some very difficult to analyze logs.
Component: JavaScript: GC → DOM
Whiteboard: [MemShrink]
These probably just show up as detached and not ghost windows because it is a local file or something.
Summary: top(none)/detached window objects are not being reclaimed by GC → Ghost windows with emunittest 0.5 suite
"Save concise" GC edges log of the run that consumes 17GB
"Save concise" CC edges log of the run that consumes 17GB
Saved about:memory report of the ghost windows.
This feels a little like bug 1213640, though you said that you opened a new tab, and closed all of the rest, so I guess it can't be the same thing.
"Save verbose" CC edges log of the run that consumes 17GB
According to the CC log, these windows are being held alive by DOM Console objects, through the mWindow field. These Console objects have a refcount of two. One reference is from the nsGlobalWindow, and the other is unknown. Andrea, do you have any idea what might be going on here?

Jukka, do you have any kind of web console thing open? I'm not entirely sure what Console corresponds to.
Thanks for peeking into these Andrew!

I don't have any console windows open, there is only one tab that I have open now, which is the about:memory  tab that I have taken the log captures from.
Here is another STR:

1. Visit https://s3.amazonaws.com/mozilla-games/OpenWebGamesTestHarness/index.html
2. Click on Run(normal) of the Stealth demo.
3. Wait until it finishes - you may have to click on "allow popups" tab at the top.
4. Open a new empty tab.
5. Close the previous OpenWebGamesTestHarness tab.
6. Navigate to about:memory
7. Click through CC/GC/Minimize memory usage
8. Click on Measure

Observed: the log shows

├──409.52 MB (49.34%) -- top(none)/detached/window(https://s3.amazonaws.com/mozilla-games/OpenWebGamesTestHarness/2015-08-29-emunittest_0.4-Stealth-u5.1.3f1_hg-e1.34.6-release-prof/index.html?playback)

which does not like to get freed.
I don't see the detached windows with the steps in comment 10 on OSX. It looks like you have e10s disabled. What version is this? Can you reproduce in a clean profile?
E10s was disabled to attempt to get a callstack to for bug 1241166. The issue occurred on both current FF Nightly, and manually built from trunk with DMD enabled, both on Windows.

Went to about:support and hit Refresh Nightly.. to reset the profile, and after that the issue did no longer occur with the STR from comment 10, but the issue does still occur in emunittest suite. Annoying.. looking now further into this to find a good way to carry the repro over.
Can you reproduce this still now that bug 1241339 landed?
Flags: needinfo?(jujjyl)
Whiteboard: [MemShrink] → [MemShrink:P1]
Doing more exhaustive runs today, I am no longer seeing the issue, so calling this resolved. Thanks!
Status: NEW → RESOLVED
Closed: 8 years ago
Flags: needinfo?(jujjyl)
Resolution: --- → FIXED
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: