{"record":{"id":"bb22a6c40e86af54","repo":"apache/hadoop","slug":"task-memory-allocation-may-not-be-0","errorCode":null,"errorMessage":"Task memory allocation may not be < 0","messagePattern":"Task memory allocation may not be < 0","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobConf.java","lineNumber":2116,"sourceCode":"   * mapreduce.map.memory.mb\n   * and mapreduce.map.memory.mb,mapred\n   * each of the new key are set\n   * as mapred.task.maxvmem / 1024\n   * as new values are in MB\n   *\n   * @param vmem Maximum amount of virtual memory in bytes any task of this job\n   *             can use.\n   * @see #getMaxVirtualMemoryForTask()\n   * @deprecated\n   *  Use {@link #setMemoryForMapTask(long mem)}  and\n   *  Use {@link #setMemoryForReduceTask(long mem)}\n   */\n  @Deprecated\n  public void setMaxVirtualMemoryForTask(long vmem) {\n    LOG.warn(\"setMaxVirtualMemoryForTask() is deprecated.\"+\n      \"Instead use setMemoryForMapTask() and setMemoryForReduceTask()\");\n    if (vmem < 0) {\n      throw new IllegalArgumentException(\"Task memory allocation may not be < 0\");\n    }\n\n    if(get(JobConf.MAPRED_TASK_MAXVMEM_PROPERTY) == null) {\n      setMemoryForMapTask(vmem / (1024 * 1024)); //Changing bytes to mb\n      setMemoryForReduceTask(vmem / (1024 * 1024));//Changing bytes to mb\n    }else{\n      this.setLong(JobConf.MAPRED_TASK_MAXVMEM_PROPERTY,vmem);\n    }\n  }\n\n  /**\n   * @deprecated this variable is deprecated and nolonger in use.\n   */\n  @Deprecated\n  public long getMaxPhysicalMemoryForTask() {\n    LOG.warn(\"The API getMaxPhysicalMemoryForTask() is deprecated.\"\n              + \" Refer to the APIs getMemoryForMapTask() and\"\n              + \" getMemoryForReduceTask() for details.\");","sourceCodeStart":2098,"sourceCodeEnd":2134,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobConf.java#L2098-L2134","documentation":"Error \"Task memory allocation may not be < 0\" thrown in apache/hadoop.","triggerScenarios":"Thrown at hadoop-mapreduce-project/hadoop-mapreduce-client/hadoop-mapreduce-client-core/src/main/java/org/apache/hadoop/mapred/JobConf.java:2116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set mapred.task.maxvmem / task memory configuration to a non-negative value in the JobConf."],"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"}