public void changeMaximumAmountOfMemory ( final long readCacheMaxMemory ) throws IllegalStateException { MemoryData memoryData ; MemoryData newMemoryData ; final int newMemorySize = normalizeMemory ( readCacheMaxMemory , pageSize ) ; do { memoryData = memoryDataContainer . get ( ) ; if ( memoryData . maxSize == newMemorySize ) { return ; } if ( ( 100 * memoryData . pinnedPages / newMemorySize ) > percentOfPinnedPages ) { throw new IllegalStateException ( "Cannot decrease amount of memory used by disk cache " + "because limit of pinned pages will be more than allowed limit " + percentOfPinnedPages ) ; } newMemoryData = new MemoryData ( newMemorySize , memoryData . pinnedPages ) ; } while ( ! memoryDataContainer . compareAndSet ( memoryData , newMemoryData ) ) ; // if (newMemorySize < memoryData.maxSize) // removeColdestPagesIfNeeded(); OLogManager . instance ( ) . info ( this , "Disk cache size was changed from " + memoryData . maxSize + " pages to " + newMemorySize + " pages" ) ; }
Changes amount of memory which may be used by given cache . This method may consume many resources if amount of memory provided in parameter is much less than current amount of memory .