@Override
  public void tick() {
    memoryLog.put(System.currentTimeMillis(), MemoryInterface.getUsedMemoryPercent());

    if (memoryLog.size() % 200 == 0) {
      // Clear out our data to clear memory.
      Iterator<Long> it = memoryLog.keySet().iterator();
      while (it.hasNext()) {
        if (it.next() < SmartRestart.getInstance().getConf().getMemorySamplePeriod()) {
          it.remove();
        } else {
          break;
        }
      }
    }
  }
  @Override
  public boolean isCriteriaViolated() {
    if (memoryLog.isEmpty()
        || memoryLog.firstKey()
            > System.currentTimeMillis()
                - SmartRestart.getInstance().getConf().getTickSamplePeriod()) {
      return false;
    }

    float val = 0;
    SortedMap<Long, Float> subset =
        memoryLog.tailMap(
            System.currentTimeMillis()
                - SmartRestart.getInstance().getConf().getMemorySamplePeriod());
    for (Float f : subset.values()) {
      val += f;
    }

    val /= subset.size();

    return MemoryInterface.getUsedMemoryPercent() >= val;
  }