uraimo / run-on-arch-action

A Github Action that executes jobs/commands on non-x86 cpu architectures (ARMv6, ARMv7, aarch64, s390x, ppc64le, riscv64) via QEMU
BSD 3-Clause "New" or "Revised" License
677 stars 149 forks source link

Node.js memory limit #77

Open hrueger opened 2 years ago

hrueger commented 2 years ago

Hi @uraimo, first of all, thanks for this excellent action. I use it quite a lot.

Unfortunately, I have an issue: I run Node.js inside the containers for my build and it always crashes with JavaScript heap out of memory although I have set then env variable NODE_OPTIONS: "--max_old_space_size=8048".

I created a debug workflow:

name: Debug
on:
  push:

env:
  NODE_OPTIONS: "--max_old_space_size=8048"

jobs:
  build_qemu:
    name: Debug ${{ matrix.arch }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        arch: [armhf]
    steps:
    - uses: actions/checkout@master
    - name: Set Swap Space
      uses: pierotofy/set-swap-space@master
      with:
        swap-size-gb: 10
    - name: Build
      uses: uraimo/run-on-arch-action@v2.1.1
      id: build
      with:
        arch: "${{ fromJSON('{\"armhf\": \"armv7\"}')[matrix.arch] }}"
        distro: ubuntu18.04
        env: |
          NODE_OPTIONS: --max_old_space_size=8048
        setup: |
          mkdir -p "${PWD}/artifacts"
        dockerRunArgs: |
          --volume "${PWD}/artifacts:/artifacts"
        install: |
          apt-get update && apt-get install -y curl
          curl -fsSL https://deb.nodesource.com/setup_16.x | bash -
          apt-get install -y nodejs
          npm install --global yarn
        githubToken: ${{ github.token }}
        run: |
          node -e "console.log(require('v8').getHeapStatistics())"
          node -e "console.log(process.env)"

As you can see, I even set more swap space and the env variable twice.

The output is:

{
  total_heap_size: 3960832,
  total_heap_size_executable: 524288,
  total_physical_size: 3154768,
  total_available_size: 4166532276,
  used_heap_size: 2419216,
  heap_size_limit: 4169138176,
  malloced_memory: 131164,
  peak_malloced_memory: 320576,
  does_zap_garbage: 0,
  number_of_native_contexts: 1,
  number_of_detached_contexts: 0
}
{
  _: '/usr/bin/node',
  GITHUB_WORKSPACE: '/home/runner/work/redacted/redacted',
  PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
  GITHUB_WORKFLOW: 'Debug',
  GITHUB_RUN_NUMBER: '6',
  GITHUB_EVENT_NAME: 'push',
  GITHUB_REPOSITORY: 'redacted/redacted',
  SHLVL: '1',
  GITHUB_JOB: 'build_qemu',
  TERM: 'xterm',
  GITHUB_BASE_REF: '',
  RUNNER_OS: 'Linux',
  GITHUB_GRAPHQL_URL: 'https://api.github.com/graphql',
  GITHUB_EVENT_PATH: '/home/runner/work/_temp/_github_workflow/event.json',
  GITHUB_SERVER_URL: 'https://github.com/',
  GITHUB_RUN_ID: 'redacted',
  GITHUB_SHA: 'redacted',
  GITHUB_REF: 'refs/heads/main',
  RUNNER_WORKSPACE: '/home/runner/work/redacted',
  DEBIAN_FRONTEND: 'noninteractive',
  GITHUB_ENV: '/home/runner/work/_temp/_runner_file_commands/set_env_redacted',
  RUNNER_TEMP: '/home/runner/work/_temp',
  HOME: '/root',
  PWD: '/home/runner/work/redacted/redacted',
  GITHUB_ACTION: 'build',
  GITHUB_ACTOR: 'hrueger',
  GITHUB_HEAD_REF: '',
  CI: 'true',
  GITHUB_ACTIONS: 'true',
  RUNNER_TOOL_CACHE: '/opt/hostedtoolcache',
  GITHUB_API_URL: 'https://api.github.com/',
  NODE_OPTIONS: '--max_old_space_size=8048',
  HOSTNAME: 'd6d6e1f2994f'
}

It seems like the memory available inside the contianer / qemu is only 4 GB, because the env variable is passed correctly.

Do you have any idea?