code: public static long getXmxValue(String javaChildOptsStr) {
      long retVal = 0L;
      String valueStr = extractXmxValueStr(javaChildOptsStr);
      char lastChar = valueStr.charAt(valueStr.length() - 1);
      try {
        if (Character.isLetter(lastChar)) {
          String xmxValStr = valueStr.substring(0, valueStr.length() - 1);
          retVal = Long.parseLong(xmxValStr);
          switch (lastChar) {
          case 'M':
          case 'm':
            // do nothing, since it's already in megabytes
            break;
          case 'K':
          case 'k':
            // convert kilobytes to megabytes
            retVal /= 1024;
            break;
          case 'G':
          case 'g':
            // convert gigabytes to megabtyes
            retVal *= 1024;
            break;
          default:
            throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr
                + " invalid value for Xmx " + xmxValStr);
         }
        } else {
          retVal = Long.parseLong(valueStr);
          // now convert to megabytes
          // since this was in bytes since the last char was absent
          retVal /= (1024 * 1024);
        }
      } catch (NumberFormatException nfe) {
        LOG.error("Unable to get the Xmx value from " + javaChildOptsStr + "\n", nfe);
        throw new ProcessingException("Unable to get the Xmx value from " + javaChildOptsStr, nfe);
      }
      return retVal;
    }
docs: parses the -Xmx value from the mapred.child.java.opts
  in the job conf usually appears as the
  following in the job conf:
  "mapred.child.java.opts" : "-Xmx3072M"
  or
  "mapred.child.java.opts" :" -Xmx1024m -verbose:gc -Xloggc:/tmp/@taskid@.gc
  @return xmx value in MB