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
$ node -v | |
v8.4.0 | |
$ node --v8-options | grep gc | |
--gc_global (always perform global GCs) | |
--gc_interval (garbage collect after <n> allocations) | |
--retain_maps_for_n_gc (keeps maps alive for <n> old space garbage collections) | |
--trace_gc (print one trace line following each garbage collection) | |
--trace_gc_nvp (print one detailed trace line in name=value format after each garbage collection) | |
--trace_gc_ignore_scavenger (do not print trace line after scavenger collection) | |
--trace_gc_verbose (print more details following each garbage collection) |
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
#!/usr/bin/env node | |
// node --expose-gc --trace-gc cases/leak-and-gc.js --normal | node cases/pipe-gc-parser.js | |
// node --expose-gc --trace-gc-nvp cases/leak-and-gc.js --normal | node cases/pipe-gc-parser.js | |
"use strict"; | |
const readline = require("readline"); | |
const GcParser = require("v8-gc-log-parser"); |
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
$ node --expose-gc --trace-gc --trace-gc-verbose ./cases/leak-and-gc.js --normal | |
[44972:0x103000000] Fast promotion mode: false survival rate: 57% | |
[44972:0x103000000] 60 ms: Scavenge 3.0 (5.5) -> 2.7 (6.5) MB, 1.2 / 0.0 ms allocation failure | |
[44972:0x103000000] Memory allocator, used: 6656 KB, available: 1459712 KB | |
[44972:0x103000000] New space, used: 581 KB, available: 425 KB, committed: 2048 KB | |
[44972:0x103000000] Old space, used: 778 KB, available: 0 KB, committed: 1024 KB | |
[44972:0x103000000] Code space, used: 1180 KB, available: 1 KB, committed: 1536KB | |
[44972:0x103000000] Map space, used: 201 KB, available: 0 KB, committed: 512 KB | |
[44972:0x103000000] Large object space, used: 0 KB, available: 1459191 KB, committed: 0 KB | |
[44972:0x103000000] All spaces, used: 2741 KB, available: 1459617 KB, committed: 5120KB |
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
#!/usr/bin/env node | |
// $ node -v | |
// v8.4.0 | |
/** | |
Debug输出信息的查看,使用: | |
DEBUG=MEM:* node xxx.js | |
查看内存输出日志: | |
DEBUG=MEM:ReportMemory node ... |
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
--log_gc (Log heap samples on garbage collection for the hp2ps tool.) | |
type: bool default: false | |
--expose_gc (expose gc extension) | |
type: bool default: false | |
--max_new_space_size (max size of the new generation (in kBytes)) | |
type: int default: 0 | |
--max_old_space_size (max size of the old generation (in Mbytes)) | |
type: int default: 0 | |
--max_executable_size (max size of executable memory (in Mbytes)) | |
type: int default: 0 |
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
// $ node -v | |
// v8.4.0 | |
// node --max-old-space-size=8192 | |
"use strict"; | |
var v8 = require("v8"); | |
console.log(v8.getHeapStatistics()); | |
// { total_heap_size: 9437184, | |
// total_heap_size_executable: 3145728, |
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
// $ node -v | |
// v8.4.0 | |
"use strict"; | |
var v8 = require("v8"); | |
console.log(v8.getHeapStatistics()); | |
// { total_heap_size: 9437184, | |
// total_heap_size_executable: 3145728, | |
// total_physical_size: 6928200, |
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
"use strict"; | |
const msgpack = require('msgpack5')(); | |
const msgpacklite = require("msgpack-lite"); | |
const obj = {name: "jonathan", age: 29, gender: "male"}; | |
const count = 100000; | |
const try5 = (act) => { | |
if (act === "encode") { | |
for (let i = 0; i < count; i++) { |
NewerOlder