code: private int getMemory(final int requestedMemory) {
      final int maxMemory = applicationResponse.getMaximumResourceCapability().getMemory();
      final int amMemory;
  
      if (requestedMemory <= maxMemory) {
        amMemory = requestedMemory;
      } else {
        LOG.log(Level.WARNING,
            "Requested {0}MB of memory for the driver. " +
                "The max on this YARN installation is {1}. " +
                "Using {1} as the memory for the driver.",
            new Object[]{requestedMemory, maxMemory});
        amMemory = maxMemory;
      }
      return amMemory;
    }
docs: Extract the desired driver memory from jobSubmissionProto.
  <p>
  returns maxMemory if that desired amount is more than maxMemory