{"record":{"id":"c150f3c8b4c6cfe5","repo":"openjdk/jdk","slug":"oom-error-in-native-tmp-buffer-allocation","errorCode":null,"errorMessage":"OOM error in native tmp buffer allocation","messagePattern":"OOM error in native tmp buffer allocation","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/java.instrument/share/native/libinstrument/JPLISAgent.c","lineNumber":788,"sourceCode":"            agent->mRedefineAdded = JNI_TRUE;\n        }\n    }\n}\n\nstatic jobject\ngetModuleObject(jvmtiEnv*               jvmti,\n                jobject                 loaderObject,\n                const char*             cname) {\n    jvmtiError err = JVMTI_ERROR_NONE;\n    jobject moduleObject = NULL;\n\n    /* find last slash in the class name */\n    const char* last_slash = (cname == NULL) ? NULL : strrchr(cname, '/');\n    int len = (last_slash == NULL) ? 0 : (int)(last_slash - cname);\n    char* pkg_name_buf = (char*)malloc(len + 1);\n\n    if (pkg_name_buf == NULL) {\n        fprintf(stderr, \"OOM error in native tmp buffer allocation\");\n        return NULL;\n    }\n    if (last_slash != NULL) {\n        strncpy(pkg_name_buf, cname, len);\n    }\n    pkg_name_buf[len] = '\\0';\n\n    err = (*jvmti)->GetNamedModule(jvmti, loaderObject, pkg_name_buf, &moduleObject);\n    free((void*)pkg_name_buf);\n    check_phase_ret_blob(err, NULL);\n    jplis_assert_msg(err == JVMTI_ERROR_NONE, \"error in the JVMTI GetNamedModule\");\n\n    return moduleObject;\n}\n\n/*\n *  Support for the JVMTI callbacks\n */","sourceCodeStart":770,"sourceCodeEnd":806,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.instrument/share/native/libinstrument/JPLISAgent.c#L770-L806","documentation":"getModuleObject failed to malloc a small buffer for the package name before calling JVMTI GetNamedModule (used when the agent asks the JVM to load a class into a module via ToInstrumentableModuleName/transform). It prints the message and returns NULL, so that instrumentation lookup fails. Pure out-of-native-memory condition.","triggerScenarios":"Native heap exhausted when the agent performs class-file transformation that resolves a class's module; container memory cap reached; RSS limits.","commonSituations":"Heavy retransformation workloads under tight container limits; JVMs with large heaps on small physical memory; leaky co-loaded native libraries consuming the process address space.","solutions":["Increase the container/process memory limit or reduce -Xmx to leave native headroom","Reduce retransformation batch sizes so transient native allocations are smaller","Use NativeMemoryTracking (jcmd VM.native_memory) to find native consumers","Check for leaks in other native agents / off-heap caches with pmap or jemalloc profiling"],"exampleFix":"# before\njava -Xmx8g --container-memory=8g -javaagent:agent.jar -jar app.jar\n# after: leave native headroom\njava -Xmx6g --container-memory=8g -javaagent:agent.jar -jar app.jar","handlingStrategy":"validation","validationCode":"// before heavy retransformation, assert native headroom\n((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean());\nlong free = Runtime.getRuntime().freeMemory(); // heap proxy only; pair with container RSS metric externally","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep container limit - max heap >= a few hundred MB for native allocations","Batch class retransformations instead of transforming everything at once"],"tags":["java-instrument","out-of-memory","native","transformation","modules"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}