Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Node.js memory limit #77

Open
hrueger opened this issue Apr 18, 2022 · 0 comments
Open

Node.js memory limit #77

hrueger opened this issue Apr 18, 2022 · 0 comments

Comments

@hrueger
Copy link

hrueger commented Apr 18, 2022

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant