New issue
Advanced search Search tips

Issue 749502 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Closed: Feb 2018
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug

Blocking:
issue 773722



Sign in to add a comment

DevTools: live WeakMap values are missing from heap snapshot.

Project Member Reported by u...@chromium.org, Jul 27 2017

Issue description

The attached html file adds many (Key, Value) items into the global weak_map.
The keys are retained separately in a global keys array.

Since keys are alive, all values are also alive (due to ephemeron semantics of WeakMaps). You can see it from the size of the heap (700MB). However, heap snapshot does not show any Value object. Console log of DevTools has warnings like
"Heap snapshot: 3034 nodes are unreachable from the root. Following nodes have only weak retainers:
  onload @3485  weak retainers: (Global handles)@29.205
  Value @7165  weak retainers: @51345.2266
  Value @7181  weak retainers: @51345.3228
  Value @7189  weak retainers: @51345.1822
  Value @7197  weak retainers: @51345.1490
  Value @7205  weak retainers: @51345.788
..."

The heap snapshot generator treats WeakMap values as simple weak references, which is incorrect. The (key, value) pairs in WeakMaps should be treated as ephemerons.
 
weak-map-retaining-path.html
765 bytes View Download
Blocking: 773722

Comment 3 by u...@chromium.org, Feb 13 2018

Owner: u...@chromium.org
Status: Assigned (was: Untriaged)
Project Member

Comment 4 by bugdroid1@chromium.org, Feb 26 2018

The following revision refers to this bug:
  https://chromium.googlesource.com/v8/v8.git/+/e8925ad5096720435a24cced75da5143d846de8e

commit e8925ad5096720435a24cced75da5143d846de8e
Author: Ulan Degenbaev <ulan@chromium.org>
Date: Mon Feb 26 11:35:45 2018

[heap-profiler] Show key as the value retainer for weak maps.

The key -> value edge is shown as "<index> / WeakMap", where <index> is
the index of the edge in the key.

Bug:  chromium:778739 ,  chromium:749502 
Change-Id: I657051695f2a171372788dbb777543a55a35d554
Reviewed-on: https://chromium-review.googlesource.com/926524
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: Alexei Filippov <alph@chromium.org>
Cr-Commit-Position: refs/heads/master@{#51559}
[modify] https://crrev.com/e8925ad5096720435a24cced75da5143d846de8e/src/profiler/heap-snapshot-generator.cc
[modify] https://crrev.com/e8925ad5096720435a24cced75da5143d846de8e/test/cctest/test-heap-profiler.cc

Comment 5 by u...@chromium.org, Feb 26 2018

Status: Fixed (was: Assigned)

Sign in to add a comment