-
Notifications
You must be signed in to change notification settings - Fork 30k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leak in async/await #9339
Comments
@nodejs/v8 |
I think it might be the same problem as: #6673 |
could you please file a bug on crbug.com/v8/new |
Okay, seems fixed in a more recent V8. May I know the schedule for 5.5? :) |
Guess this patch is required to fix the leak: https://bugs.chromium.org/p/v8/issues/detail?id=5390 |
FYI, the fix for https://bugs.chromium.org/p/v8/issues/detail?id=5390 made into V8 version -- 5.5.232.0 |
Per https://www.chromium.org/developers/calendar, V8 5.5 release is expected around 2016-12-06. |
I think it should be possible to fix it in babel as well |
Possibly interesting for babel -- leebyron/async-to-gen#26 |
do we really need babel,, when nodejs 7.0.0 is out ? |
This is a known issue with v8. It has been verified and fixed in 5.5 which should be integrated later on. Quoting @littledan
|
As there is no workaround from the Node side I am aware of and we don't plan to realistically backport this v8 patch without a v8 upgrade I think the issue should be closed. If anyone has anything else to add feel free to reopen. |
Too bad, was looking forward to ditching Babel in favor of native async-await soon. |
Sorry about this historical bug! |
You shouldn't use harmony flags in production, when a feature is ready and stable enough — it's enabled by default. If something is disabled — it is either not finished, has issues, or was not tested enough. Specifically async/await is enabled in V8 5.5, which should be released in December, and will get into some Node.js release after that, either 7.x.0 or 8.0.0, depending on whether there would be API/ABI incompatibilities in the V8 update. |
@ChALkeR right, my |
So this seems to be closed a long time ago.
|
@mgamsjager it's not actual leaking, but small sample size with random lazy GC Try the following edited code with bigger loop size and manual GC trigger: const testFunc = () => {
const run = async () => {
let idx = 0
const thresh = 1e6
const limit = 1e9 // increased loop count
while (idx++ < limit) {
const record = await get()
if (idx % thresh === 0) {
global.gc() // trigger GC
console.log('heap-used:', process.memoryUsage().heapUsed, record)
}
}
}
const get = async () => ({ foo: 'foo', bar: 'bar' })
run()
}
process.exit(require('child_process').spawnSync( // run with a GC-enabled node process
process.argv0,
[
'--expose-gc', // allow `global.gc()` call
'--max-old-space-size=4', // limit max memory usage
'--eval', `(${testFunc})()`
],
{ stdio: 'inherit' }
).status) Or the shell command if you do not want a file: node --expose-gc --max-old-space-size=4 --eval "$(cat <<- 'EOM'
const run = async () => {
let idx = 0
const thresh = 1e6
const limit = 1e9 // increased loop count
while (idx++ < limit) {
const record = await get()
if (idx % thresh === 0) {
global.gc() // trigger GC
console.log('heap-used:', process.memoryUsage().heapUsed, record)
}
}
}
const get = async () => ({ foo: 'foo', bar: 'bar' })
run()
EOM
)" My test result end up stays the same with
and with
|
Here's the code. Heap usage grows:
Run with
node --harmony-async-await
, for Node 7.0.0.P.S. If you remove async/await from
function get
, everything is fine. Withoutasync/await
it's also so much faster!P.P.S. Original issue babel/babel#4382
The text was updated successfully, but these errors were encountered: