Last active
June 16, 2017 22:51
-
-
Save timothyb89/6e72d0c4ec45abae8b328efbf0e140ef to your computer and use it in GitHub Desktop.
GCF memory usage bug
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const child_process = require('child_process'); | |
const os = require('os'); | |
function debug() { | |
const free = os.freemem(); | |
const total = os.totalmem(); | |
console.log('process: ', process.memoryUsage(), 'os: ', { | |
free, total, | |
usedMiB: (total - free) / (1024 * 1024) | |
}); | |
} | |
function spawn(command, args, options = {}) { | |
return new Promise((resolve, reject) => { | |
const child = child_process.spawn(command, args, options); | |
child.on('error', err => { | |
reject(err); | |
}); | |
child.on('close', code => { | |
if (code === 0) { | |
resolve(code); | |
} else { | |
reject(code); | |
} | |
}); | |
}); | |
} | |
function spawn_child() { | |
return spawn('ls', ['/']).then(() => { | |
debug(); | |
}); | |
} | |
function reproduce_async_spawn(req, res) { | |
spawn_child() | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(spawn_child) | |
.then(() => { | |
res.status(200).send('success').end(); | |
}) | |
.catch(err => { | |
console.log(err); | |
res.status(500).send('failure').end(); | |
}); | |
} | |
function reproduce_sync_exec(req, res) { | |
for (let i = 0; i < 10; i++) { | |
child_process.execSync('ls /'); | |
debug(); | |
} | |
res.status(200).send('done').end(); | |
} | |
function reproduce_sync_spawn(req, res) { | |
for (let i = 0; i < 10; i++) { | |
child_process.spawnSync('ls' ['/']); | |
debug(); | |
} | |
res.status(200).send('done').end(); | |
} | |
module.exports = { | |
reproduce_async_spawn, | |
reproduce_sync_exec, | |
reproduce_sync_spawn | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
D reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:40.667 Function execution started | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.004 process: { rss: 0, heapTotal: 19959808, heapUsed: 11545824 } os: { free: 1964847104, total: 2147483648, usedMiB: 174.17578125 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.174 process: { rss: 0, heapTotal: 19959808, heapUsed: 12194952 } os: { free: 1912225792, total: 2147483648, usedMiB: 224.359375 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.355 process: { rss: 0, heapTotal: 19959808, heapUsed: 12315200 } os: { free: 1860149248, total: 2147483648, usedMiB: 274.0234375 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.468 process: { rss: 0, heapTotal: 19959808, heapUsed: 12383104 } os: { free: 1808109568, total: 2147483648, usedMiB: 323.65234375 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.578 process: { rss: 0, heapTotal: 19959808, heapUsed: 12455688 } os: { free: 1756065792, total: 2147483648, usedMiB: 373.28515625 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.757 process: { rss: 0, heapTotal: 19959808, heapUsed: 12540984 } os: { free: 1704005632, total: 2147483648, usedMiB: 422.93359375 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.870 process: { rss: 0, heapTotal: 19959808, heapUsed: 12602944 } os: { free: 1651965952, total: 2147483648, usedMiB: 472.5625 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:41.980 process: { rss: 0, heapTotal: 19959808, heapUsed: 12677600 } os: { free: 1599922176, total: 2147483648, usedMiB: 522.1953125 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:42.157 process: { rss: 0, heapTotal: 21008384, heapUsed: 12771520 } os: { free: 1548132352, total: 2147483648, usedMiB: 571.5859375 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:42.279 process: { rss: 0, heapTotal: 21008384, heapUsed: 12875224 } os: { free: 1495957504, total: 2147483648, usedMiB: 621.34375 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:42.383 process: { rss: 0, heapTotal: 21008384, heapUsed: 12952008 } os: { free: 1443995648, total: 2147483648, usedMiB: 670.8984375 } | |
I reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:42.562 process: { rss: 0, heapTotal: 21008384, heapUsed: 13069160 } os: { free: 1391910912, total: 2147483648, usedMiB: 720.5703125 } | |
D reproduce_async_spawn k7hje5hwji8h 2017-06-16 22:48:42.565 Function execution took 1899 ms, finished with status code: 200 | |
D reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:49.156 Function execution started | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:49.516 process: { rss: 0, heapTotal: 19959808, heapUsed: 11396448 } os: { free: 1973428224, total: 2147483648, usedMiB: 165.9921875 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:49.638 process: { rss: 0, heapTotal: 19959808, heapUsed: 11930808 } os: { free: 1920274432, total: 2147483648, usedMiB: 216.68359375 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:49.832 process: { rss: 0, heapTotal: 19959808, heapUsed: 11954440 } os: { free: 1876713472, total: 2147483648, usedMiB: 258.2265625 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:50.023 process: { rss: 0, heapTotal: 19959808, heapUsed: 11975128 } os: { free: 1832968192, total: 2147483648, usedMiB: 299.9453125 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:50.131 process: { rss: 0, heapTotal: 19959808, heapUsed: 11995784 } os: { free: 1789841408, total: 2147483648, usedMiB: 341.07421875 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:50.329 process: { rss: 0, heapTotal: 19959808, heapUsed: 12016440 } os: { free: 1754652672, total: 2147483648, usedMiB: 374.6328125 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:50.520 process: { rss: 0, heapTotal: 19959808, heapUsed: 12037128 } os: { free: 1702539264, total: 2147483648, usedMiB: 424.33203125 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:50.717 process: { rss: 0, heapTotal: 19959808, heapUsed: 12057784 } os: { free: 1658363904, total: 2147483648, usedMiB: 466.4609375 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:50.832 process: { rss: 0, heapTotal: 19959808, heapUsed: 12078440 } os: { free: 1615265792, total: 2147483648, usedMiB: 507.5625 } | |
I reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:51.024 process: { rss: 0, heapTotal: 19959808, heapUsed: 12099080 } os: { free: 1571155968, total: 2147483648, usedMiB: 549.62890625 } | |
D reproduce_sync_spawn qb4dbmrcxogh 2017-06-16 22:48:51.031 Function execution took 1876 ms, finished with status code: 200 | |
D reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:56.677 Function execution started | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:57.103 process: { rss: 0, heapTotal: 19959808, heapUsed: 11418752 } os: { free: 1957081088, total: 2147483648, usedMiB: 181.58203125 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:57.300 process: { rss: 0, heapTotal: 19959808, heapUsed: 11956832 } os: { free: 1889603584, total: 2147483648, usedMiB: 245.93359375 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:57.501 process: { rss: 0, heapTotal: 19959808, heapUsed: 11980960 } os: { free: 1834307584, total: 2147483648, usedMiB: 298.66796875 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:57.626 process: { rss: 0, heapTotal: 19959808, heapUsed: 12002144 } os: { free: 1776574464, total: 2147483648, usedMiB: 353.7265625 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:57.818 process: { rss: 0, heapTotal: 19959808, heapUsed: 12023328 } os: { free: 1716580352, total: 2147483648, usedMiB: 410.94140625 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:58.005 process: { rss: 0, heapTotal: 19959808, heapUsed: 12044480 } os: { free: 1656586240, total: 2147483648, usedMiB: 468.15625 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:58.201 process: { rss: 0, heapTotal: 19959808, heapUsed: 12065624 } os: { free: 1596592128, total: 2147483648, usedMiB: 525.37109375 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:58.404 process: { rss: 0, heapTotal: 19959808, heapUsed: 12086776 } os: { free: 1529561088, total: 2147483648, usedMiB: 589.296875 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:58.606 process: { rss: 0, heapTotal: 19959808, heapUsed: 12107952 } os: { free: 1476599808, total: 2147483648, usedMiB: 639.8046875 } | |
I reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:58.803 process: { rss: 0, heapTotal: 19959808, heapUsed: 12129104 } os: { free: 1416605696, total: 2147483648, usedMiB: 697.01953125 } | |
D reproduce_sync_exec oz4wjlqdcnui 2017-06-16 22:48:58.808 Function execution took 2131 ms, finished with status code: 200 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment