code: void gc() {
      UfsJournalSnapshot snapshot;
      try {
        snapshot = UfsJournalSnapshot.getSnapshot(mJournal);
      } catch (IOException e) {
        LOG.warn("Failed to get journal snapshot with error {}.", e.getMessage());
        return;
      }
      long checkpointSequenceNumber = 0;
  
      // Checkpoint.
      List<UfsJournalFile> checkpoints = snapshot.getCheckpoints();
      if (!checkpoints.isEmpty()) {
        checkpointSequenceNumber = checkpoints.get(checkpoints.size() - 1).getEnd();
      }
      for (int i = 0; i < checkpoints.size() - 1; i++) {
        // Only keep at most 2 checkpoints.
        if (i < checkpoints.size() - 2) {
          deleteNoException(checkpoints.get(i).getLocation());
        }
        // For the the second last checkpoint. Check whether it has been there for a long time.
        gcFileIfStale(checkpoints.get(i), checkpointSequenceNumber);
      }
  
      for (UfsJournalFile log : snapshot.getLogs()) {
        gcFileIfStale(log, checkpointSequenceNumber);
      }
  
      for (UfsJournalFile tmpCheckpoint : snapshot.getTemporaryCheckpoints()) {
        gcFileIfStale(tmpCheckpoint, checkpointSequenceNumber);
      }
    }
docs: Deletes unneeded snapshots.