{"record":{"id":"ee09cc5577300972","repo":"openjdk/jdk","slug":"oom-error-in-native-tmp-buffer-allocation-ee09cc","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/windows/native/libinstrument/FileSystemSupport_md.c","lineNumber":62,"sourceCode":"static int isLetter(char c) {\n    return ((c >= 'a') && (c <= 'z')) || ((c >= 'A') && (c <= 'Z'));\n}\n\nchar* basePath(const char* path) {\n    char* pos = strchr(path, slash);\n    char* last = NULL;\n    while (pos != NULL) {\n        last = pos;\n        pos++;\n        pos = strchr(pos, slash);\n    }\n    if (last == NULL) {\n        return (char*)path;\n    } else {\n        int len = (int)(last - path);\n        char* str = (char*)malloc(len+1);\n        if (str == NULL) {\n            fprintf(stderr, \"OOM error in native tmp buffer allocation\");\n            return NULL;\n        }\n        if (len > 0) {\n            memcpy(str, path, len);\n        }\n        str[len] = '\\0';\n        return str;\n    }\n}\n\n\n\n/* -- Normalization - src/windows/classes/java/io/Win32FileSystem.java */\n\n\n/* A normal Win32 pathname contains no duplicate slashes, except possibly\n * for a UNC prefix, and does not end with a slash.  It may be the empty\n * string.  Normalized Win32 pathnames have the convenient property that","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/openjdk/jdk/blob/88dfb74bbeefcf2b0aa11835183bcd949998fc8f/src/java.instrument/windows/native/libinstrument/FileSystemSupport_md.c#L44-L80","documentation":"Windows counterpart of basePath(): it scans for the last path separator and mallocs a copy of the directory portion of a path during libinstrument's agent JAR resolution on Windows. If malloc fails, this message is printed and NULL returned, aborting agent startup. It is a native allocation failure, independent of the path's correctness.","triggerScenarios":"Running java -javaagent:agent.jar on Windows when the native heap cannot satisfy a tiny allocation: process working set/commit limit exhausted, Job Object memory caps, or severe native fragmentation from other DLLs loaded at startup.","commonSituations":"Windows containers or Job Objects with tight commit limits; machines under heavy memory pressure; AV/EDR software injecting DLLs that consume native memory before the JVM starts; 32-bit JVMs near the 2/4GB address-space ceiling.","solutions":["Free system memory or raise the commit limit / Job Object cap before starting the JVM","If using a 32-bit JVM with a big -Xmx, reduce heap reservation or move to 64-bit so native allocations have room","Check for DLL-injecting security software competing for native memory at startup","Reproduce outside the constrained environment to confirm the agent and path are fine"],"exampleFix":"rem before (32-bit JVM, -Xmx1600m leaves no native headroom)\njava -Xmx1600m -javaagent:C:\\agents\\agent.jar -jar app.jar\n\nrem after\njava -Xmx1024m -javaagent:C:\\agents\\agent.jar -jar app.jar","handlingStrategy":"validation","validationCode":"rem Pre-launch checks on Windows\nrem 1. System commit headroom: (Get-CimInstance Win32_OperatingSystem).FreePhysicalMemory and FreeVirtualMemory should be well above a few hundred MB\nrem 2. Prefer 64-bit java.exe: where java   -> confirm path is under a 64-bit JDK\nrem 3. Job Object / container caps: verify the memory quota exceeds -Xmx + ~512MB\njava -agentlib:... -javaagent:C:\\agents\\agent.jar -jar app.jar","typeGuard":null,"tryCatchPattern":"// Native malloc failure inside libinstrument is not a Java exception; catch at the process level:\n// launch the JVM from a wrapper that checks the exit code and memory counters, then reports environment failure.","preventionTips":["Run 64-bit JVMs in memory-constrained Windows deployments","Keep -Xmx at least 512MB below the process memory quota on 32-bit JVMs","Test agents on the exact Windows image (with AV/EDR present) before rollout"],"tags":["native","oom","memory","javaagent","libinstrument","windows","path-handling"],"backgroundTag":null,"analyzedSha":"88dfb74bbeefcf2b0aa11835183bcd949998fc8f","analyzedAt":"2026-08-14T11:45:09.665Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}