@VisibleForTesting
  String getFinalJvmOptions(String jvmOpts, String maxHeapOverride) {
    String finalJvmOpts = jvmOpts;
    if (new JobConfig(this).getAutosizingEnabled() && StringUtils.isNotEmpty(maxHeapOverride)) {
      String xmxSetting = "-Xmx" + maxHeapOverride + "m";
      if (StringUtils.isNotBlank(jvmOpts)) {
        if (jvmOpts.contains("-Xmx")) {
          finalJvmOpts = jvmOpts.replaceAll("-Xmx\\S+", xmxSetting);
        } else {
          finalJvmOpts = jvmOpts.concat(" " + xmxSetting);
        }
      } else {
        finalJvmOpts = xmxSetting;
      }
    }

    return finalJvmOpts;
  }
Returns the final JVM options by applying the heap override if available to the jvm opts
samza-core/src/main/java/org/apache/samza/config/ShellCommandConfig.java