public void clean(){
  ChronoFullRevision cfr=firstCFR;
  totalSize=size;
  while (cfr != null) {
    totalSize+=cfr.size();
    cfr=cfr.getNext();
  }
  if (totalSize < MAX_STORAGE_SIZE) {
    return;
  }
  cfr=firstCFR;
  while (cfr != null) {
    totalSize+=cfr.clean(revisionIndex,0);
    cfr=cfr.getNext();
  }
  ChronoStorageBlock block;
  while (last != null && totalSize >= MAX_STORAGE_SIZE) {
    block=last.getIndexPrev();
    if (storage.remove(last.getRevisionIndex()) == null) {
      throw new RuntimeException("VALUE WAS NOT REMOVED FROM STORAGE");
    }
    totalSize-=last.length();
    size+=last.length();
    if (block != null) {
      block.setIndexNext(null);
    }
    last.setIndexPrev(null);
    cfr=last.getChronoFullRevision();
    totalSize+=cfr.size() - cfr.clean(revisionIndex,last.getRevisionIndex());
    if (last == first) {
      first=null;
    }
    last=block;
  }
  System.gc();
}

public void clean ( ) { ChronoFullRevision cfr = firstCFR ; totalSize = size ; while ( cfr != null ) { totalSize += cfr . size ( ) ; cfr = cfr . getNext ( ) ; } if ( totalSize < MAX_STORAGE_SIZE ) { return ; } cfr = firstCFR ; while ( cfr != null ) { totalSize += cfr . clean ( revisionIndex , 0 ) ; cfr = cfr . getNext ( ) ; } ChronoStorageBlock block ; while ( last != null && totalSize >= MAX_STORAGE_SIZE ) { block = last . getIndexPrev ( ) ; if ( storage . remove ( last . getRevisionIndex ( ) ) == null ) { throw new RuntimeException ( "VALUE WAS NOT REMOVED FROM STORAGE" ) ; } totalSize -= last . length ( ) ; size += last . length ( ) ; if ( block != null ) { block . setIndexNext ( null ) ; } last . setIndexPrev ( null ) ; cfr = last . getChronoFullRevision ( ) ; totalSize += cfr . size ( ) - cfr . clean ( revisionIndex , last . getRevisionIndex ( ) ) ; if ( last == first ) { first = null ; } last = block ; } System . gc ( ) ; }
reduces the amount of used storage by discarding chrono storage blocks .
