Node.js 20+ automatically adjusts heap size based on container memory limits through cgroup awareness. By default, heap size is 50% of container memory up to 4 Gi, maxing out at 2 GB. The --max-old-space-size flag can override these defaults. The article explains V8 garbage collection behavior, troubleshooting memory leaks, and deployment considerations for OpenShift/Kubernetes environments. Key insight: simply increasing heap size won't fix underlying memory leaks, as OutOfMemory exceptions will eventually occur regardless.

7m read timeFrom developers.redhat.com
Post cover image
Table of contents
Node.js 20 inside a containerNode.js requests versus limitsNode.js memory managementV8 garbage collection behaviorDeploying Node.js 20 on OpenShiftTroubleshootingSummaryDemo videoConclusion

Sort: