next.js 下一个Router Worker使用太多内存

oxosxuxt  于 2023-11-18  发布在  其他
关注(0)|答案(1)|浏览(165)

我的Next.js应用程序使用了大量的服务器内存。内存使用量不断增长。似乎在next-router-worker进程中存在内存泄漏。我在服务器上看到htop命令的输出:

应用程序运行在生产环境中,根据官方文档构建。服务器节点版本为18.18.2。
我尝试过更改Next.js包的不同版本,但没有效果。我当前的package.json如下:

{
  "name": "app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "dev": "next dev -p 3000",
    "build": "next build",
    "start": "next start",
    "lint": "next lint"
  },
  "dependencies": {
    "@tanstack/react-query": "^4.32.6",
    "axios": "^1.4.0",
    "axios-extensions": "^3.1.6",
    "dayjs": "^1.11.7",
    "jotai": "^2.1.0",
    "next": "13.5",
    "react": "18.2.0",
    "react-currency-input-field": "^3.6.11",
    "react-dom": "18.2.0",
    "react-google-recaptcha": "^3.1.0",
    "react-input-mask": "^2.0.4",
    "react-slick": "^0.29.0",
    "react-transition-group": "^4.4.5",
    "sass": "^1.62.1",
    "slick-carousel": "^1.8.1"
  },
  "devDependencies": {
    "@testing-library/react": "^14.0.0",
    "@types/node": "20.2.5",
    "@types/react": "18.2.7",
    "@types/react-dom": "18.2.4",
    "@types/react-google-recaptcha": "^2.1.5",
    "@types/react-input-mask": "^3.0.2",
    "@types/react-slick": "^0.23.10",
    "@types/react-transition-group": "^4.4.6",
    "eslint": "8.41.0",
    "eslint-config-next": "13.4.4",
    "replace-in-file": "^7.0.1",
    "typescript": "5.0.4"
  }
}

字符串
有什么问题吗?除了更改版本,我还能尝试什么?

tpgth1q7

tpgth1q71#

同样的,在Ubuntu 18上以2cpu 0.5G RAM VPS托管。
在从NextJs中删除任何与API相关的内容后。替换为原始的html标签就可以了。它变得不那么重了。

  • 这只是一个非常小项目,使用Next-Auth、Mantine JS和Next JS 13.6.5,页面仅使用API显示300 x图片。

my htop printscreen, that time server before hang

相关问题