Skip to content
Latchkey

CodeQL out-of-memory during database create in CI

CodeQL extraction holds significant state in memory. On a large project, a standard runner can run out of RAM, at which point the OS kills the extractor and database create fails abnormally.

What this error means

The CodeQL step dies with an out-of-memory signal, "Killed", or a Java "OutOfMemoryError" during extraction, often after running for several minutes.

CodeQL
[extractor] java.lang.OutOfMemoryError: Java heap space
Spawned process exited abnormally (code 137, exit reason was: Killed)

Common causes

The default runner has too little RAM

A 7 GB standard runner cannot hold the extraction state for a very large codebase, so the kernel kills the process (exit 137).

Extractor RAM/threads are not tuned

Default parallelism can multiply memory use; without limits the extractor peaks above available RAM.

How to fix it

Use a larger runner

Move the CodeQL job to a runner with more memory so extraction fits.

.github/workflows/codeql.yml
jobs:
  analyze:
    runs-on: ubuntu-latest-8-cores

Cap extractor RAM and threads

Constrain CodeQL memory and threads so peak usage stays under the runner limit.

.github/workflows/codeql.yml
- uses: github/codeql-action/init@v3
  with:
    languages: cpp
    ram: 5000
    threads: 2

How to prevent it

  • Match runner memory to codebase size for CodeQL jobs.
  • Set the ram and threads inputs for large extractions.
  • Split very large monorepos into per-language or per-module scans.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →