public void testPurge() throws Exception {
  List<MemoryFile> files=new ArrayList<MemoryFile>();
  try {
    while (true) {
      MemoryFile newFile=new MemoryFile("MemoryFileTest",10000000);
      newFile.allowPurging(true);
      newFile.writeBytes(testString,0,0,testString.length);
      files.add(newFile);
      for (      MemoryFile file : files) {
        try {
          file.readBytes(testString,0,0,testString.length);
        }
 catch (        IOException e) {
          return;
        }
      }
    }
  }
  finally {
    for (    MemoryFile fileToClose : files) {
      fileToClose.close();
    }
  }
}

public void testPurge ( ) throws Exception { List < MemoryFile > files = new ArrayList < MemoryFile > ( ) ; try { while ( true ) { MemoryFile newFile = new MemoryFile ( "MemoryFileTest" , 10000000 ) ; newFile . allowPurging ( true ) ; newFile . writeBytes ( testString , 0 , 0 , testString . length ) ; files . add ( newFile ) ; for ( MemoryFile file : files ) { try { file . readBytes ( testString , 0 , 0 , testString . length ) ; } catch ( IOException e ) { return ; } } } } finally { for ( MemoryFile fileToClose : files ) { fileToClose . close ( ) ; } } }
keep allocating new files till the system purges them .
