Description
Node.js Version
18.20.1
NPM Version
10.5.0
Operating System
Linux 51d05a3105c7 6.10.4-linuxkit #1 SMP Wed Oct 2 16:38:00 UTC 2024 x86_64 GNU/Linux
Subsystem
fs, https, process, v8, Other
Description
Hello, I've ExpreesJS application and I'm facing memory limit reached on prod server, Which is rss
reaching memory limit
When I run the application locally on Mac M1
machine I've normal rss, heap usage
the rss
start at z90MB
go up to 150MB
on load and in few seconds it will be freed to be back at 100MB
.
But on my docker container the rss
start at 400MB
and goes up to 500MB
on some load and it doesn't free at all, maybe in few minutes it free 1-5MB but that's it.
{
rss: '503.9 MB',
heapTotal: '139.45 MB',
heapUsed: '115.81 MB',
external: '142.88 MB',
arrayBuffers: '140.09 MB'
}
heap seems to be normal, and since when I run the node on my local machine the rss
is normal too I can say is not related to any native libraries I use. So can it be from docker image ?
Docker file:
# Use the official lightweight Node.js 18 image.
# https://hub.docker.com/_/node
FROM node:18.20.1
# Create and change to the app directory.
WORKDIR /usr/src/app
# Copy application dependency manifests to the container image.
# A wildcard is used to ensure both package.json AND package-lock.json are copied.
# Copying this separately prevents re-running npm install on every code change.
COPY package.json ./
# RUN npm install pm2 -g
# Install dependencies.
RUN npm install --omit=dev
# Copy local code to the container image.
COPY . ./
# Run the web service on container startup.
CMD ["node", "server.js"]
I also tried to use libjemalloc
but same result
RUN apt-get update && apt-get install -y \
libjemalloc-dev
RUN echo "/usr/lib/x86_64-linux-gnu/libjemalloc.so" >> /etc/ld.so.preload
Any tips on debugging this ?
Minimal Reproduction
No response
Output
No response
Before You Submit
- I have looked for issues that already exist before submitting this
- My issue follows the guidelines in the README file, and follows the 'How to ask a good question' guide at https://stackoverflow.com/help/how-to-ask