{"record":{"id":"5eb6f35917212e9a","repo":"oracle/graal","slug":"error-out-of-memory-for-counts","errorCode":null,"errorMessage":"Error: out of memory for counts\n","messagePattern":"Error: out of memory for counts\n","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"compiler/src/org.graalvm.papibridge/src/papibridge.c","lineNumber":152,"sourceCode":"/**\n * Stops the measurements for the specified PAPI event set and returns the counts.\n *\n * @param env The JNI environment.\n * @param cls The Java class that this native method belongs to.\n * @param eventset The handle of the event set to be stopped.\n *\n * @return A Java long array containing the event counts, or NULL if an error occurs.\n */\nJNIEXPORT jlongArray JNICALL Java_jdk_graal_compiler_hotspot_replaycomp_HardwarePerformanceCounters_stop(JNIEnv *env, jclass cls, jint eventset) {\n    int numberOfEvents = 0;\n    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}","sourceCodeStart":134,"sourceCodeEnd":170,"githubUrl":"https://github.com/oracle/graal/blob/a66e9ccd1d7bf2552883939aa0788dfd0e294aab/compiler/src/org.graalvm.papibridge/src/papibridge.c#L134-L170","documentation":"Error \"Error: out of memory for counts\n\" thrown in oracle/graal.","triggerScenarios":"Thrown at compiler/src/org.graalvm.papibridge/src/papibridge.c:152 when the library encounters an invalid state.","commonSituations":"Occurs when a caller violates the contract guarded by this check: Error: out of memory for counts","solutions":["Fix the condition reported by the error: Error: out of memory for counts","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: out of memory for counts","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"}