openjdk/jdk · critical

Error: Out of memory in ADLC\n

Error message

Error: Out of memory in ADLC\n

What it means

ADLC (the HotSpot Architecture Description Language compiler, built and run during the JDK build to generate match tables from .ad files) failed its heap allocation in AdlAllocateHeap: malloc() returned NULL for a non-zero size. The tool prints 'Error: Out of memory in ADLC' to stderr and immediately exits with status 1, aborting the JVM build.

Source

Thrown at src/hotspot/share/adlc/adlArena.cpp:30

 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 * or visit www.oracle.com if you need additional information or have any
 * questions.
 *
 */

#include "adlc.hpp"

void* AdlAllocateHeap(size_t size) {
  unsigned char* ptr = (unsigned char*) malloc(size);
  if (ptr == nullptr && size != 0) {
    fprintf(stderr, "Error: Out of memory in ADLC\n"); // logging can cause crash!
    fflush(stderr);
    exit(1);
  }
  return ptr;
}

void* AdlReAllocateHeap(void* old_ptr, size_t size) {
  unsigned char* ptr = (unsigned char*) realloc(old_ptr, size);
  if (ptr == nullptr && size != 0) {
    fprintf(stderr, "Error: Out of memory in ADLC\n"); // logging can cause crash!
    fflush(stderr);
    exit(1);
  }
  return ptr;
}

void* AdlChunk::operator new(size_t requested_size, size_t length) throw() {
  assert(requested_size <= SIZE_MAX - length, "overflow");

View on GitHub (pinned to 88dfb74bbe)

Solutions

  1. Free memory or raise the container/VM memory limit, then rerun make
  2. Check 'ulimit -v' and 'ulimit -m' in the build shell; raise or unset virtual memory limits
  3. Reduce parallelism of the build (JOBS=... / make -j) so adlc is not competing for RAM
  4. If it reproduces deterministically on a specific .ad change, bisect the .ad edit — an accidental exponential MatchRule expansion may be the real cause

Example fix

# before
ulimit -v 2097152  # 2GB virtual cap -> adlc OOM
make images

# after
ulimit -v unlimited
make images
Defensive patterns

Strategy: validation

Validate before calling

# run before the build
free_mem=$(awk '/MemAvailable/{print int($2/1024)}' /proc/meminfo)
vlimit=$(ulimit -v); [ "$vlimit" != "unlimited" ] && [ "$vlimit" -lt 4194304 ] && echo "raise ulimit -v" && exit 1

Prevention

When it happens

Trigger: AdlAllocateHeap(size) is the single allocation entry point for all ADLC arenas/chunks (AdlChunk::operator new routes here). It fails when the process cannot get more memory — huge .ad platform description files, arena growth during phase-2 DFA generation, or a constrained build environment (ulimit -v, container memory cap, out of swap).

Common situations: Building the JDK inside a Docker/CI container with a low memory limit; ulimit -v set for the build shell; very large architectural changes to a cpu .ad file that blow up MatchList/DFA memory; parallel make jobs (HIGH_MEM make targets like adlc) exhausting RAM.

Related errors


AI-assisted analysis of openjdk/jdk@88dfb74bbe (2026-08-14). Data as JSON: /api/errors/9c51418dd9755c62. Report an issue: GitHub.