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

Container 'Build' exceeded memory limit. Android

Krunal Pandav November 28, 2022
Hi,
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?
currently my repository size is 2.11 GB is it can matter for pipeline?
Thank you very much.


image
: androidsdk/android-30
definitions:
services:
docker:
memory: 512
docker-with-more-memory:
memory: 2048
type: docker
docker-with-large-memory:
memory: 5120
type: docker
pipelines:
branches:
master:
#- parallel:
- step:
size: 2x
name: Build
caches:
- gradle
script:
- echo "$GOOGLE_SERVICES_JSON" | base64 -di > app/google-services.json
- echo "$SIGNING_JKS_FILE" | base64 -di > android-signing-keystore.jks
- ./gradlew assembleRelease
artifacts:
- app/build/outputs/**
- step:
size: 2x
name: Build Debug
caches:
- gradle
script:
- echo "$GOOGLE_SERVICES_JSON" | base64 -di > app/google-services.json
- echo "$SIGNING_JKS_FILE" | base64 -di > android-signing-keystore.jks
- ./gradlew assembleDebug
artifacts:
- app/build/outputs/**
- step:
size: 2x
name: Test
caches:
- gradle
script:
- ./gradlew test
- step:
size: 2x
name: Push On Production
#trigger: manual
script:
- echo "$GOOGLE_SERVICES_JSON" | base64 -di > app/google-services.json
- echo $GOOGLE_API_KEY_JSON | base64 -di > google_play_api_key.json
- echo "$SIGNING_JKS_FILE" | base64 -di > android-signing-keystore.jks
- ./gradlew :app:publishReleaseBundle
artifacts:
- app/build/outputs/

2 answers

1 accepted

0 votes
Answer accepted
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 29, 2022

Hey Krunal,

Welcome to the Bitbucket Cloud community!

I would suggest including the following line of code in your bitbucket-pipelines.yml file to the affected step - this will allow you to determine which part of the step is exceeding the build memory limit:

- while true; do date && echo "Memory usage in megabytes:" && echo $((`cat /sys/fs/cgroup/memory/memory.memsw.usage_in_bytes | awk '{print $1}'`/1048576)) && echo "" && sleep 30; done &

 

Cheers!

- Ben (Bitbucket Cloud Support)

Krunal Pandav December 14, 2022

I'm getting issue on below step

step:
size2x
nameTest
caches:
gradle
script:
./gradlew test

in which section i put this solution?
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
December 14, 2022

Hey Krunal,

You would put it in the "script" section at the top :)

Cheers!

- Ben (Bitbucket Cloud Support)

0 votes
Krunal Pandav April 16, 2023

Hey i was update my pipeline with your suggestion but it happen every some time period what is the reason for that what i change for that?

 again I'm getting this "Container 'Build' exceeded memory limit." error.

my pipeline code is below and i'm gettin memory lint error in last step.

 

image: androidsdk/android-30
definitions:
services:
docker:
memory: 1024
docker-with-more-memory:
memory: 4096
type: docker
docker-with-large-memory:
memory: 10240
type: docker
caches:
gradle:
key:
files:
- build.gradle
path: ~/.gradle/caches
pipelines:
branches:
master:
#- parallel:
- step:
size: 2x
name: Build Variants
caches:
- gradle
script:
- echo "$GOOGLE_SERVICES_JSON" | base64 -di > app/google-services.json
- echo "$SIGNING_JKS_FILE" | base64 -di > android-signing-keystore.jks
- ./gradlew assembleRelease
- step:
size: 2x
name: Build Debug
caches:
- gradle
script:
- echo "$GOOGLE_SERVICES_JSON" | base64 -di > app/google-services.json
- echo "$SIGNING_JKS_FILE" | base64 -di > android-signing-keystore.jks
- ./gradlew assembleDebug
- step:
size: 2x
name: Push On Production
script:
- echo "$GOOGLE_SERVICES_JSON" | base64 -di > app/google-services.json
- echo $GOOGLE_API_KEY_JSON | base64 -di > google_play_api_key.json
- echo "$SIGNING_JKS_FILE" | base64 -di > android-signing-keystore.jks
- while true; do date && echo "Memory usage in megabytes:" && echo $((`cat /sys/fs/cgroup/memory/memory.memsw.usage_in_bytes | awk '{print $1}'`/1048576)) && echo "" && sleep 30; done &
- ./gradlew :app:publishReleaseBundle --no-daemon
please suggest for that what i change ?
Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 17, 2023

Hey Krunal,

I've noticed based on your yml config that you've assigned 10240 to the docker-with-large-memory service container.

Pipelines builds have a maximum of 8GB to assign memory for when using the "size: 2x" build step - so the above definition will cause the build to fail automatically as it exceeds the maximum limit.

The 8GB of memory consists of 1GB for the build container, so realistically you only have 7GB total remaining - when you factor in the docker service containers - whichever container is being used is subtracted from this 7GB pool.

This means if you were to have a build step using the docker-with-more-memory service container for example - the remaining memory used by the step container would only be 3GB (8GB - 1GB build container - 4GB service container = 3GB remaining).

I would highly suggest reading through our documentation related to Pipelines, and if you need more than 8GB I would suggest making use of self-hosted runners:

Cheers!

- Ben (Bitbucket Cloud Support)

Krunal Pandav April 25, 2023

what we define first in definitions section caches or services?

Ben
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
April 26, 2023

Hi @Krunal Pandav I usually define services first and this is what I would recommend. Your issue relates to the assigned memory, however - as per my previous reply.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events