{"record":{"id":"b6c5c106ed2892a8","repo":"oracle/graal","slug":"error-could-not-allocate-java-long-array","errorCode":null,"errorMessage":"Error: could not allocate Java long array\n","messagePattern":"Error: could not allocate Java long array\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.papibridge/src/papibridge.c","lineNumber":163,"sourceCode":"    int retval = PAPI_list_events(eventset, NULL, &numberOfEvents);\n    if (retval != PAPI_OK || numberOfEvents <= 0) {\n        fprintf(stderr, \"Error: unable to retrieve event count for event set %d: %s\\n\", eventset, PAPI_strerror(retval));\n        return NULL;\n    }\n    long long *counts = (long long *) malloc(numberOfEvents * sizeof(long long));\n    if (counts == NULL) {\n        fprintf(stderr, \"Error: out of memory for counts\\n\");\n        return NULL;\n    }\n    retval = PAPI_stop(eventset, counts);\n    if (retval != PAPI_OK) {\n        fprintf(stderr, \"Error stopping measurements for event set %d: %s\\n\", eventset, PAPI_strerror(retval));\n        free(counts);\n        return NULL;\n    }\n    jlongArray result = (*env)->NewLongArray(env, numberOfEvents);\n    if (result == NULL) {\n        fprintf(stderr, \"Error: could not allocate Java long array\\n\");\n        free(counts);\n        return NULL;\n    }\n    (*env)->SetLongArrayRegion(env, result, 0, numberOfEvents, (jlong *) counts);\n    free(counts);\n    return result;\n}\n","sourceCodeStart":145,"sourceCodeEnd":171,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.papibridge/src/papibridge.c#L145-L171","documentation":"Error \"Error: could not allocate Java long array\n\" thrown in oracle/graal.","triggerScenarios":"Thrown at compiler/src/org.graalvm.papibridge/src/papibridge.c:163 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Error: could not allocate Java long array","solutions":["Fix the condition reported by the error: Error: could not allocate Java long array","Check the throwing call site and ensure its documented preconditions (argument values, types, environment, or configuration) are satisfied before the call."],"exampleFix":"Validate inputs and environment so that the failing condition does not occur: Error: could not allocate Java long array","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a66e9ccd1d7bf2552883939aa0788dfd0e294aab","analyzedAt":"2026-08-14T13:58:47.161Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}