code: private static FactorComparator<Executor> getMemoryComparator(final int weight) {
      return FactorComparator.create(MEMORY_COMPARATOR_NAME, weight, new Comparator<Executor>() {
  
        @Override
        public int compare(final Executor o1, final Executor o2) {
          final ExecutorInfo stat1 = o1.getExecutorInfo();
          final ExecutorInfo stat2 = o2.getExecutorInfo();
  
          final int result = 0;
          if (statisticsObjectCheck(stat1, stat2, MEMORY_COMPARATOR_NAME)) {
            return result;
          }
  
          if (stat1.getRemainingMemoryInMB() != stat2.getRemainingMemoryInMB()) {
            return stat1.getRemainingMemoryInMB() > stat2.getRemainingMemoryInMB() ? 1 : -1;
          }
  
          return Double.compare(stat1.getRemainingMemoryPercent(), stat2.getRemainingMemoryPercent());
        }
      });
    }
docs: <pre>
  function defines the Memory comparator.
  Note: comparator firstly take the absolute value of the remaining memory, if both sides have
  the same value,
  it go further to check the percent of the remaining memory.
  </pre>
  
  @param weight weight of the comparator.