{"record":{"id":"8e18ace2054cd535","repo":"apache/hadoop","slug":"can-not-allocate-memory-memory-used-memoryused","errorCode":null,"errorMessage":"Can not allocate memory, memory used {memoryUsed}, allocate size {size}, memory limit {memoryLimit}","messagePattern":"Can not allocate memory, memory used (.+?), allocate size (.+?), memory limit (.+?)","errorType":"exception","errorClass":"MemoryLimitException","httpStatus":null,"severity":"error","filePath":"hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/OSSDataBlocks.java","lineNumber":462,"sourceCode":"    void setMemoryLimit(long memoryLimit) {\n      this.memoryLimit = memoryLimit;\n      if (memoryLimit > 0) {\n        checkMemory = true;\n      }\n    }\n\n    void allocateMemory(long size) throws MemoryLimitException {\n      if (!checkMemory) {\n        return;\n      }\n      long next = memoryUsed.addAndGet(size);\n      if (next > memoryLimit) {\n        memoryUsed.getAndAdd(-size);\n        String msg = \"Can not allocate memory\"\n                + \", memory used \" + memoryUsed\n                + \", allocate size \" + size\n                + \", memory limit \" + memoryLimit;\n        throw new MemoryLimitException(msg);\n      }\n    }\n\n    void releaseMemory(long size) {\n      if (!checkMemory) {\n        return;\n      }\n      memoryUsed.getAndAdd(-size);\n    }\n\n    long getMemoryUsed() {\n      return memoryUsed.get();\n    }\n  }\n\n  /**\n   * Use byte arrays on the heap for storage.\n   */","sourceCodeStart":444,"sourceCodeEnd":480,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/OSSDataBlocks.java#L444-L480","documentation":"Error \"Can not allocate memory, memory used {memoryUsed}, allocate size {size}, memory limit {memoryLimit}\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-tools/hadoop-aliyun/src/main/java/org/apache/hadoop/fs/aliyun/oss/OSSDataBlocks.java:462 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Increase fs.oss.data.blocks.buffer.memory.limit or reduce the number of active upload streams so buffered memory stays under the limit."],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}