Skip to content

内存溢出 #2

Description

@Tinkser

代码

function printMemoryUsage(tag = '') {
    const used = process.memoryUsage();
    console.log(`\n--- Memory Usage ${tag} ---`);
    for (let key in used) {
        console.log(`${key}: ${(used[key] / 1024 / 1024).toFixed(2)} MB`);
    }
}
var faker = require("./nodePlug/faker");

for (let i = 0; i < 100000000; i++) {
    let demo = ()=>{}
    let [x1,x2] = faker.new_document_all(demo)
    if (i%100000===0) {
        printMemoryUsage();
    }
    [x1,x2] = [null,null];
    demo = null;
}

执行之后

--- Memory Usage  ---
rss: 4215.17 MB
heapTotal: 4127.07 MB
heapUsed: 4038.40 MB
external: 2.28 MB
arrayBuffers: 0.02 MB

<--- Last few GCs --->

[25712:000002455DFF3000]    22823 ms: Scavenge 4060.9 (4134.1) -> 4060.1 (4135.6) MB, pooled: 0 MB, 6.10 / 0.00 ms  (average mu = 0.210, current mu = 0.102) allocation failure;
[25712:000002455DFF3000]    22840 ms: Scavenge 4064.1 (4137.3) -> 4063.7 (4147.6) MB, pooled: 0 MB, 9.29 / 0.00 ms  (average mu = 0.210, current mu = 0.102) allocation failure;


<--- JS stacktrace --->

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions