-
Notifications
You must be signed in to change notification settings - Fork 42
Open
Description
const fs = require('fs');
const hash = require('hash.js')
async function main() {
let data = await fs.promises.readFile('large126MBfile', { encoding: 'utf8' });
console.log('before');
let sha256 = hash.sha256().update(data).digest('hex');
console.log('after');
}
main();
output is:
# node --max-old-space-size=67108864 test.js
before
<--- Last few GCs --->
[418310:0x5299b80] 1363 ms: Scavenge 867.2 (900.6) -> 867.2 (900.6) MB, 20.2 / 0.0 ms (average mu = 0.984, current mu = 0.984) allocation failure
[418310:0x5299b80] 1620 ms: Scavenge 1249.7 (1283.2) -> 1249.7 (1283.2) MB, 30.1 / 0.0 ms (average mu = 0.984, current mu = 0.984) allocation failure
[418310:0x5299b80] 2004 ms: Scavenge 1823.5 (1857.0) -> 1823.5 (1857.0) MB, 44.4 / 0.0 ms (average mu = 0.984, current mu = 0.984) allocation failure
<--- JS stacktrace --->
==== JS stack trace =========================================
0: ExitFrame [pc: 0x13ad8f9]
Security context: 0x1ff9fbdc0921 <JSObject>
1: toArray [0x185c4cec0df1] [/root/node_modules/hash.js/lib/hash/utils.js:~18] [pc=0x1bdd2c9cad7b](this=0x185c4cec0829 <Object map = 0x10a9e2ec3051>,0x07ae208c0121 <Very long string[131054357]>,0x1e42e08004b9 <undefined>)
2: update [0x150c16f71df9] [/root/node_...
FATAL ERROR: invalid array length Allocation failed - JavaScript heap out of memory
Writing Node.js report to file: report.20220409.203712.418310.0.001.json
Node.js report completed
1: 0x9f1420 node::Abort() [node]
2: 0x9f36e2 node::OnFatalError(char const*, char const*) [node]
3: 0xb5865e v8::Utils::ReportOOMFailure(v8::internal::Isolate*, char const*, bool) [node]
4: 0xb589d9 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [node]
5: 0xd064e5 [node]
6: 0xcdf111 [node]
7: 0xce0df2 v8::internal::Factory::NewUninitializedFixedArray(int) [node]
8: 0xe518cf [node]
9: 0xe51b6d [node]
10: 0x1003b8b v8::internal::Runtime_GrowArrayElements(int, unsigned long*, v8::internal::Isolate*) [node]
11: 0x13ad8f9 [node]
Aborted (core dumped)
Metadata
Metadata
Assignees
Labels
No labels