Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Container 'Build' exceeded memory limit. NPM

I'd like to ask you about my memory overflow problem.
I tried something but it didn't help. Sometimes it passes and sometimes it doesn't. This is a mystery to me.
Can you please give me some advice?
Thank you very much.

max-time: 30
docker: true
size: 2x

depth: full

- step:
name: Build client app
image: node:14-slim
- npm
- cd client/app
- npm ci
- npm run build
- npm run lint

- step:
name: Build server app
image: node:14-slim
- npm
- cd server/app
- npm ci
- npm run build

npm: $HOME/.npm
memory: 6144

1 answer

1 accepted

0 votes
Answer accepted
Caroline R Atlassian Team Mar 22, 2022

Hi, @frantisek_lorenc, welcome to the community! 

I've analyzed your build setup and noticed that you are currently allocating 6 GB for your docker service, which means you only have 2 GB for your build container. This seems to be the reason why your build is intermittently failing due to memory issues (depending on changes you are making on your code, this can influence the amount of memory your build will need to use and throw you this error).

Just to give you a background on how memory is allocated in the build container, regular steps have 4096 MB of memory in total, large build steps (which you can define using size: 2x) have 8192 MB in total. Service containers (like the docker service ) get 1024 MB memory by default, but can be configured to use between 128 MB and the step maximum (3072/7128 MB).

Currently, on your bitbucket-pipelines.yml file, you have set the pipeline to use size: 2x, as per the following sections from your yml file:

max-time: 30
docker: true
size: 2x

Since this is configured as size:2x, this means that each step will be provided with 8192 MB of memory, of which 6144MB is being reserved for the docker service, leaving 2048 MB for the build container that runs your script commands. Since you are reported that sometimes it passes and sometimes it doesn't, it looks this memory is not sufficient for the build to complete, and hence the error you are getting.

That being said, I would suggest you decrease the memory being allocated to the docker service by using the following definition on your YML file:

memory: 5120 

This will allocate 5120 MB to the docker service. You can test it with 5120, and if it fails you can keep decreasing this value until your build is stable.

After adjusting your YML file, you can try running the build again and check if the issue is fixed.

You can also refer to the following documentation for more details about Pipeline memory limits:

Do let us know if you run into any issues trying the suggestions above, or if you have any other questions.

Kind regards,

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events