0

I am doing a memory dump on the instance where ng build is triggered. I can show the time where number of processes are spawned by ng build. Is there way to control this number.

              total        used        free      shared  buff/cache   available
Mem:            30G        8.5G        2.7G        215M         19G         21G
Swap:            0B          0B          0B
Fri Jan 27 15:07:19 UTC 2023
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   4288   708 ?        Ss   15:02   0:00 /bin/sh -c exit $( (/usr/bin/mkfifo /opt/atlassian/pipelines/agent/tmp/build_result && /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result) || /bin/echo 1)
root           8  0.0  0.0   4288    96 ?        S    15:02   0:00 /bin/sh -c exit $( (/usr/bin/mkfifo /opt/atlassian/pipelines/agent/tmp/build_result && /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result) || /bin/echo 1)
root           9  0.0  0.0   4200   716 ?        S    15:02   0:00 /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result
root          11  0.0  0.0   4288  1460 ?        Ss   15:02   0:00 /bin/sh /opt/atlassian/pipelines/agent/tmp/wrapperScript14257846929627798257.sh
root          35  0.0  0.0   4288   764 ?        S    15:02   0:00 /bin/sh /opt/atlassian/pipelines/agent/tmp/buildScript1578831321044327918.sh
root          36  0.0  0.0  18004  2936 ?        S    15:02   0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript16516797543053797206.sh
root          37  0.0  0.0  18008  2416 ?        S    15:02   0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript16516797543053797206.sh
root          38  0.0  0.0  18008  2416 ?        S    15:02   0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript16516797543053797206.sh
root          40  0.0  0.0  18024  2924 ?        S    15:02   0:00 bash docker-build.sh
root          60  0.0  0.1 666880 41336 ?        Sl   15:02   0:00 npm
root          71  0.0  0.0   4296   808 ?        S    15:02   0:00 sh -c npm i --unsafe-perm -g  @angular/cli &&  npm i && npm run copyi18n && npm run bump_version && node --max_old_space_size=6656 node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         327  125 10.3 4375844 3362764 ?     Rl   15:03   5:00 ng build --prod=true --base-href=/
root         574  0.0  0.0   4196   680 ?        S    15:07   0:00 sleep 5
root         576  0.0  0.0  36644  2844 ?        R    15:07   0:00 ps aux

In the above there is PID - 317 and only one ng build instance

After 10 second i see the following

Fri Jan 27 15:07:29 UTC 2023
USER         PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root           1  0.0  0.0   4288   708 ?        Ss   15:02   0:00 /bin/sh -c exit $( (/usr/bin/mkfifo /opt/atlassian/pipelines/agent/tmp/build_result && /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result) || /bin/echo 1)
root           8  0.0  0.0   4288    96 ?        S    15:02   0:00 /bin/sh -c exit $( (/usr/bin/mkfifo /opt/atlassian/pipelines/agent/tmp/build_result && /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result) || /bin/echo 1)
root           9  0.0  0.0   4200   716 ?        S    15:02   0:00 /bin/cat /opt/atlassian/pipelines/agent/tmp/build_result
root          11  0.0  0.0   4288  1460 ?        Ss   15:02   0:00 /bin/sh /opt/atlassian/pipelines/agent/tmp/wrapperScript14257846929627798257.sh
root          35  0.0  0.0   4288   764 ?        S    15:02   0:00 /bin/sh /opt/atlassian/pipelines/agent/tmp/buildScript1578831321044327918.sh
root          36  0.0  0.0  18004  2936 ?        S    15:02   0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript16516797543053797206.sh
root          37  0.0  0.0  18008  2416 ?        S    15:02   0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript16516797543053797206.sh
root          38  0.0  0.0  18008  2416 ?        S    15:02   0:00 /bin/bash -i /opt/atlassian/pipelines/agent/tmp/bashScript16516797543053797206.sh
root          40  0.0  0.0  18024  2924 ?        S    15:02   0:00 bash docker-build.sh
root          60  0.0  0.1 666880 41336 ?        Sl   15:02   0:00 npm
root          71  0.0  0.0   4296   808 ?        S    15:02   0:00 sh -c npm i --unsafe-perm -g  @angular/cli &&  npm i && npm run copyi18n && npm run bump_version && node --max_old_space_size=6656 node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         327  123 12.5 5146756 4055172 ?     Sl   15:03   5:07 ng build --prod=true --base-href=/
root         578 40.1  0.2 611084 90388 ?        Rl   15:07   0:02 /usr/local/bin/node --max_old_space_size=6656 /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/child/index.js /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         585 86.2  0.3 651124 129216 ?       Rl   15:07   0:04 /usr/local/bin/node --max_old_space_size=6656 /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/child/index.js /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         596 25.6  0.3 638388 117496 ?       Rl   15:07   0:01 /usr/local/bin/node --max_old_space_size=6656 /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/child/index.js /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         604 29.0  0.2 609828 88928 ?        Rl   15:07   0:01 /usr/local/bin/node --max_old_space_size=6656 /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/child/index.js /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         611  102  0.2 617016 95864 ?        Rl   15:07   0:04 /usr/local/bin/node --max_old_space_size=6656 /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/child/index.js /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         618 32.7  0.3 620824 99604 ?        Rl   15:07   0:01 /usr/local/bin/node --max_old_space_size=6656 /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/child/index.js /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         625 66.2  0.4 657444 136912 ?       Rl   15:07   0:02 /usr/local/bin/node --max_old_space_size=6656 /opt/atlassian/pipelines/agent/build/node_modules/worker-farm/lib/child/index.js /usr/local/bin/node /opt/atlassian/pipelines/agent/build/node_modules/@angular/cli/bin/ng build --prod=true --base-href=/
root         633  0.0  0.0   4196   652 ?        S    15:07   0:00 sleep 5
root         635  0.0  0.0  36644  2804 ?        R    15:07   0:00 ps aux

After this point the available RAM Drops and then eventually fails


              total        used        free      shared  buff/cache   available
Mem:            30G         11G        762M        169M         18G         19G
Swap:            0B          0B          0B

Bitbucket Pipeline File

  branches:
    master:
      - step:
          size: 2x
          script:
            - bash docker-build.sh

    '{dev/*,release/*,hotfix/*}':
      - step:
          size: 2x
          script:
            - while true; do date && ps aux && echo "" && sleep 5; done &
            - while true; do free -h && echo "" && sleep 5; done &
            - bash docker-build.sh

definitions:
    services:
      node:
        image: node:10.15.3
        memory: 7680
      docker:
        memory: 512

# Docker true for running docker daemon commands. By default it will be there in step
options:
  docker: true
  size: 2x

package.json snippet

{
  "name": "de-ui",
  "version": "4.7.1",
  "scripts": {
    "ng": "ng",
    "start": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
    "prod_build": "npm i --unsafe-perm -g  @angular/cli &&  npm i && npm run copyi18n && npm run bump_version && node --max_old_space_size=6656 node_modules/@angular/cli/bin/ng build --prod=true --base-href=/",
    "copyi18n": "node ./load.po.files.js ./src/assets/i18n/po/ ./src/assets/i18n/",
    "createi18npo": "node ./load.po.files.js ./src/assets/i18n/ ./src/assets/i18n/po/",
    "update_de": "npm update @de/de-ui-core @de/de-jsf-form @de/de-ui-app @de/de-ui-api",
    "bump_version": "node ./bump_version.js",
    "serve_prod": "node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng serve --prod=true"
  }

Note:

Size: 2x -- 8 GB Available
docker - Set to true
Sizing:
        node:
        image: node:10.15.3
        memory: 7680
      docker:
        memory: 512
node --max_old_space_size=6656 -- provided in ng build

1. How can i avoid so many process from getting triggered 
2. Is there way i can re arrange the memory allocation to avoid getting --> Container 'Build' exceeded memory limit.

Have tried changing the memory sizing. But not able to get it. Thinking if i the number of processes that is getting spawned can be controlled, then can handle memory issue.

0 Answers0