nodejs / nodejs/node

node only using half of the available memory

未关闭
#35,573 15 条评论 12 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

memory never-stale
主要语言
JavaScript
星标
122k
派生
37.4k
平均合并
4 天 3 小时
30 天内合并 PR
272

描述

  • Version: 12.19.0
  • Platform: Debian Buster
  • Subsystem:
What steps will reproduce the bug?
  1. Start a container with limited memory (something like docker run --rm -it --memory=1G --memory-swap=1G node:12.19.0-buster-slim bash
  2. Inspect heap size (node -e 'const v8 = require("v8"); console.log(v8.getHeapStatistics());')
How often does it reproduce? Is there a required condition?

100%

What is the expected behavior?

node would use all available memory

What do you see instead?

node is only using half of the memory, so we either need to give the container twice as much memory as we really want it to use (which is problematic) or also specify --max-old-space-size in addition to controlling the container which means we have to keep 2 different settings in sync and that's a big pain

Additional information

It appears that it was changed here, and only using half of memory makes sense when running on a system with multiple process, but when running in a docker container, using all of the memory allocated to the container makes more sense

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

首先,使用提供的 docker run 命令和 node -e v8.getHeapStatistics() 检查来复现问题。跟踪 Node.js 如何确定容器的内存限制,并将该值与预期的 1G 分配进行比较;完成的标准是运行时能够适当地设置堆大小,而不需要单独设置 --max-old-space-size。

由索引模型根据 Issue 内容生成。

评估

技术栈
docker, javascript, linux, node.js
领域
backend, devops, performance
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。