gpt4 book ai didi

javascript - 如何找到node中递归运行的函数?

转载 作者:行者123 更新时间:2023-12-01 01:19:23 25 4
gpt4 key购买 nike

我是 Node 和 Angular 开发的新手。最近,我面临这个问题 - “ fatal error :无效的标记压缩接近堆限制分配失败 - JavaScript 堆内存不足”。谁能告诉我如何找到消耗大部分内存并导致此问题的函数?我无法找出根本原因?

我正在使用 Node 服务器(Node.js):10.15.0 typescript :3.2.2

最佳答案

对此有一些解决方案。

最简单的方式是node clinic

你必须:

// install
npm install -g clinic
// run your process and see result
clinic doctor -- node my-process.js
// you can also use bubbleprof for network latency or flame for bottlenecks

当您停止该过程或该过程结束时,医生将使用该信息创建 HTML 报告。

使用标准 node args 查找问题的另一种方法:

// will generate a file isolate-0xnnnnnnnnnnnn-v8.log like (isolate-000001AADA5C7900-v8)
node --prof my-process.js
// to make it human readable
node --prof-process isolate-0xnnnnnnnnnnnn-v8.log > processed.txt

另一种方法是:

// run your process with inspect:
node --inspect=0.0.0.0:9229 my-process.js
// then run chrome dev tools and connect it to <IP>:9229
go to this url on your Chrome: chrome://inspect/#devices
// then you will able to profile the cpu and take snapshots of memory usage

PS 在 chrome 开发工具中,您将看到以下内容以打开:

open node dev tools

关于javascript - 如何找到node中递归运行的函数?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54377541/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com