Repository navigation
Memory leak in simple test case involving WeakSet #6180
Description
Activity
The problem is that somewhy only scavenges are triggered here, but mark-sweeps aren't.
And scavenges can't collect those elements (for some reason).In most real-world apps this wouldn't be a problem, because there are many things that push mark-sweep runs.
This is most likely already fixed in v8, if Chrome 49 is fine.
We should check how master is doing, I will be able to check that a bit later.- addedv8 engineIssues and PRs related to the V8 dependency.Issues and PRs related to the V8 dependency.memoryIssues and PRs related to Node.js memory management or memory footprint.Issues and PRs related to Node.js memory management or memory footprint.
on Apr 13, 2016 @ChALkeR is there write-up on which heuristics are used by v8 for different types of GC? It seems that in node v5 and earlier
WeakMapandWeakSetdon't apply any pressure on garbage collector at all@vkurchatkin That, I don't know.
/cc @jeisinger
This is most likely already fixed in v8, if Chrome 49 is fine.
No garbage collection in master with v8 4.9.385.35 and in vee-eight-5.0 with v8 5.0.71.25 on OSX El Capitan 10.11.5 Beta 1, XCode v7.3
Daniel
@dnalborczyk Same as in it gets garbage collected or not?
Are you running with 64 bit or 32 bit?
@ChALkeR Oh, sorry, same as in the original issue description. No garbage collection. I corrected the above.
Btw, if it helps, Chrome 51.0.2700.0 dev is eventually smoking up as well - though the heap size seems to remain the same ( if the output happens to be correct ). Firefox 47, Edge 14 (37), and Safari 9.1.1 keep running.
filed https://bugs.chromium.org/p/v8/issues/detail?id=4909 to track this.
btw, can you share a non-artificial example? I.e. something where you manage to fill up a weak set in a meaningful way without generating enough garbage anyways to trigger a full gc?
@ChALkeR dumb question - but can't/should't node trigger a full GC before throwing an out of memory error? I'd actually expect v8 to do that.
@benjamingr That's v8 job and somewhy it doesn't do it here. It's mentioned in the issue that @jeisinger filed to v8 issue tracker:
Maybe we should try an emergency GC before aborting in the case of weakmaps and weaksets
landed a fix in v8. turns out there was no code to actually free up GC'd slots in a weak collection... gives you an idea how much this feature is used on the web.
anyways, should probably be backmerged to node's lts version of v8
Reacted by Michaël Zasso, Nikita Skovoroda and Michał Wadas31 remaining items
- added a commit that references this issue
on Aug 14, 2017 - added a commit that references this issue
on Aug 16, 2017 - added a commit that references this issue
on Oct 25, 2017 - added a commit that references this issue
on Nov 24, 2017
Version: 4.2.1, 5.1.10 confirmed.
Platform: at least Windows 10 and Linux
`Following code reproduces error:
It ends with following output
Objects are properly garbage collected in Chrome 49 (
process.memoryUsage().heapUsedis changed toperformance.memory.usedJSHeapSize).Source: StackOverflow question.