public static long getCappedRuntimeMaxMemory(long unlimitedCap) {
    final long jvmMaxMemory = Runtime.getRuntime().maxMemory();
    return jvmMaxMemory == Long.MAX_VALUE ? unlimitedCap : jvmMaxMemory;
  }
public static long getCappedRuntimeMaxMemory(long unlimitedCap) {
    final long jvmMaxMemory = Runtime.getRuntime().maxMemory();
    return jvmMaxMemory == Long.MAX_VALUE ? unlimitedCap : jvmMaxMemory;
  }
public static long getCappedRuntimeMaxMemory ( long unlimitedCap ) { final long jvmMaxMemory = Runtime . getRuntime ( ) . maxMemory ( ) ; return jvmMaxMemory == Long . MAX_VALUE ? unlimitedCap : jvmMaxMemory ; }
@param unlimitedCap the upper limit on reported memory, if JVM reports unlimited memory.

@return same as {@link Runtime#maxMemory()} except that {@code unlimitedCap} limit is applied if JVM reports {@link
Long#MAX_VALUE unlimited memory}.
@param unlimitedCap the upper limit on reported memory if JVM reports unlimited memory .