< prev index next >

test/hotspot/jtreg/gc/arguments/TestTargetSurvivorRatioFlag.java

8217389: JTREG: Clean up, remove unused variable warnings

279          * Allocate (<b>ratio</b> * <b>maxSize</b> / 100) bytes of objects                                                 
280          * and force at least "MaxTenuringThreshold" minor GCs.                                                            
281          *                                                                                                                 
282          * @param ratio ratio used to calculate how many objects should be allocated                                       
283          * @param maxSize estimated max survivor space size                                                                
284          */                                                                                                                
285         public static void allocateMemory(double ratio, long maxSize) throws Exception {                                   
286             GarbageCollectorMXBean youngGCBean = GCTypes.YoungGCType.getYoungGCBean();                                     
287             long garbageSize = (long) (maxSize * (ratio / 100.0));                                                         
288             int arrayLength = (int) (garbageSize / CHUNK_SIZE);                                                            
289             AllocationHelper allocator = new AllocationHelper(1, arrayLength, ARRAY_LENGTH, null);                         
290 
291             System.out.println(START_TEST);                                                                                
292             System.gc();                                                                                                   
293             final long initialGcId = youngGCBean.getCollectionCount();                                                     
294             // allocate memory                                                                                             
295             allocator.allocateMemoryAndVerify();                                                                           
296 
297             // force minor GC                                                                                              
298             while (youngGCBean.getCollectionCount() <= initialGcId + MAX_TENURING_THRESHOLD * 2) {                         
                                                                                                                           
299                 byte b[] = new byte[ARRAY_LENGTH];                                                                         
300             }                                                                                                              
301 
302             allocator.release();                                                                                           
303             System.out.println(END_TEST);                                                                                  
304         }                                                                                                                  
305 
306         /**                                                                                                                
307          * Estimate max survivor space size.                                                                               
308          *                                                                                                                 
309          * For non-G1 GC returns value reported by MemoryPoolMXBean                                                        
310          * associated with survivor space.                                                                                 
311          * For G1 GC return max number of survivor regions * region size.                                                  
312          * Number if survivor regions estimated from MaxNewSize and SurvivorRatio.                                         
313          */                                                                                                                
314         public static long getMaxSurvivorSize() {                                                                          
315             if (GCTypes.YoungGCType.getYoungGCType() == GCTypes.YoungGCType.G1) {                                          
316                 int youngLength = (int) Math.max(MAX_NEW_SIZE / wb.g1RegionSize(), 1);                                     
317                 return (long) Math.ceil(youngLength / (double) SURVIVOR_RATIO) * wb.g1RegionSize();                        

279          * Allocate (<b>ratio</b> * <b>maxSize</b> / 100) bytes of objects
280          * and force at least "MaxTenuringThreshold" minor GCs.
281          *
282          * @param ratio ratio used to calculate how many objects should be allocated
283          * @param maxSize estimated max survivor space size
284          */
285         public static void allocateMemory(double ratio, long maxSize) throws Exception {
286             GarbageCollectorMXBean youngGCBean = GCTypes.YoungGCType.getYoungGCBean();
287             long garbageSize = (long) (maxSize * (ratio / 100.0));
288             int arrayLength = (int) (garbageSize / CHUNK_SIZE);
289             AllocationHelper allocator = new AllocationHelper(1, arrayLength, ARRAY_LENGTH, null);
290 
291             System.out.println(START_TEST);
292             System.gc();
293             final long initialGcId = youngGCBean.getCollectionCount();
294             // allocate memory
295             allocator.allocateMemoryAndVerify();
296 
297             // force minor GC
298             while (youngGCBean.getCollectionCount() <= initialGcId + MAX_TENURING_THRESHOLD * 2) {
299                 @SuppressWarnings("unused")
300                 byte b[] = new byte[ARRAY_LENGTH];
301             }
302 
303             allocator.release();
304             System.out.println(END_TEST);
305         }
306 
307         /**
308          * Estimate max survivor space size.
309          *
310          * For non-G1 GC returns value reported by MemoryPoolMXBean
311          * associated with survivor space.
312          * For G1 GC return max number of survivor regions * region size.
313          * Number if survivor regions estimated from MaxNewSize and SurvivorRatio.
314          */
315         public static long getMaxSurvivorSize() {
316             if (GCTypes.YoungGCType.getYoungGCType() == GCTypes.YoungGCType.G1) {
317                 int youngLength = (int) Math.max(MAX_NEW_SIZE / wb.g1RegionSize(), 1);
318                 return (long) Math.ceil(youngLength / (double) SURVIVOR_RATIO) * wb.g1RegionSize();
< prev index next >