oracle/graal · error

Error: could not allocate Java long array

Error message

Error: could not allocate Java long array

What it means

Error "Error: could not allocate Java long array " thrown in oracle/graal.

Source

Thrown at compiler/src/org.graalvm.papibridge/src/papibridge.c:163

    int retval = PAPI_list_events(eventset, NULL, &numberOfEvents);
    if (retval != PAPI_OK || numberOfEvents <= 0) {
        fprintf(stderr, "Error: unable to retrieve event count for event set %d: %s\n", eventset, PAPI_strerror(retval));
        return NULL;
    }
    long long *counts = (long long *) malloc(numberOfEvents * sizeof(long long));
    if (counts == NULL) {
        fprintf(stderr, "Error: out of memory for counts\n");
        return NULL;
    }
    retval = PAPI_stop(eventset, counts);
    if (retval != PAPI_OK) {
        fprintf(stderr, "Error stopping measurements for event set %d: %s\n", eventset, PAPI_strerror(retval));
        free(counts);
        return NULL;
    }
    jlongArray result = (*env)->NewLongArray(env, numberOfEvents);
    if (result == NULL) {
        fprintf(stderr, "Error: could not allocate Java long array\n");
        free(counts);
        return NULL;
    }
    (*env)->SetLongArrayRegion(env, result, 0, numberOfEvents, (jlong *) counts);
    free(counts);
    return result;
}

View on GitHub (pinned to a66e9ccd1d)

Solutions

  1. Fix the condition reported by the error: Error: could not allocate Java long array
  2. Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call.

Example fix

Validate inputs and environment so that the failing condition does not occur: Error: could not allocate Java long array

When it happens

Trigger: Thrown at compiler/src/org.graalvm.papibridge/src/papibridge.c:163 when the library encounters an invalid state.

Common situations: Occurs when a caller violates the contract guarded by this check: Error: could not allocate Java long array


AI-assisted analysis of oracle/graal@a66e9ccd1d (2026-08-14). Data as JSON: /api/errors/b6c5c106ed2892a8. Report an issue: GitHub.