如果通过“npm start”启动,PM2 无法读取正确的内存

问题描述

PM2 版本 0.36.0 NodeJS 15.0.1 版

结构

pm2.config.js
testpm2
├── index.js
└── package.json

pm2.config.js

module.exports ={
    "apps": [
        {
            "name": "my-test-app","cwd": "./testpm2","script": "npm","args": "start"
        }
    ]
}

index.js

const arr = [];
setInterval(() => {
  for (let i = 0; i < 100000; i += 1) {
    arr.push('12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890');
  }
  console.log('running....',arr.length);
  console.log(process.memoryUsage());

},100);

package.json

{
  "author": "","main": "index.js","scripts": {
    "start": "node ./index.js"
  },"version": "1.0.0"
}

当 pm2 运行时,pm2 monit 显示内存恒定为 49MB。它显然是在泄漏,但 pm2 未能读取正确的内存值。

enter image description here

我是否错误地配置了生态系统文件?这里发生了什么?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)