< prev index next >

test/hotspot/jtreg/vmTestbase/metaspace/gc/HighWaterMarkTest.java

Print this page




 170         System.out.println("% Committed metaspce: " + bytes2k(getCommitted()));
 171 
 172         cleanLoadedClasses();
 173 
 174         if (attempts == maxAttempts) {
 175             throw new Fault("Committed amount hasn't achieved " + bytes2k(committedLevel));
 176         }
 177 
 178         if (VMRuntimeEnvUtils.isVMOptionEnabled("UseConcMarkSweepGC")) {
 179             System.out.println("ConcMarkSweep is used, cannot count GC");
 180             return;
 181         }
 182 
 183         int gcCount = getMetaspaceGCCount();
 184         if (gcCount < 0) {
 185             // perhpas, it's better to silently pass here... Let's see.
 186             throw new Fault ("Unable to count full collections, could be an env issue");
 187         }
 188         System.out.println("% GC has been invoked: " + gcCount + " times");
 189 
 190         if (VMRuntimeEnvUtils.isVMOptionEnabled("UseG1GC") &&
 191               VMRuntimeEnvUtils.isVMOptionEnabled("ClassUnloadingWithConcurrentMark")) {
 192             System.out.println("% isG1ClassUnloading: true");
 193             if (gcCount != 0) {
 194                 throw new Fault ("G1 should unload classes, full GC is not expected");
 195             }
 196         } else {
 197             if (maxMetaspaceFreeRatio <= 1) {
 198                 // min/max = 0/1  boundary value
 199                 // GC should happen very often
 200                 checkGCCount(gcCount, 20, -1);
 201             } else if (minMetaspaceFreeRatio >= 99) {
 202                 // min/max = 99/100  boundary value
 203                 // GC should happen very rare
 204                 checkGCCount(gcCount, -1, 2);
 205             } else if (minMetaspaceFreeRatio >= 10  && maxMetaspaceFreeRatio <= 20) {
 206                 // GC should happen quite often
 207                 checkGCCount(gcCount, 3, 30);
 208             } else if (minMetaspaceFreeRatio >= 70  && maxMetaspaceFreeRatio <= 80) {
 209                 // GC should happen quite often
 210                 checkGCCount(gcCount, 1, 3);
 211             } else {
 212                 // hard to estimate
 213             }
 214         }
 215 
 216     }
 217     /**
 218      * Checks that count of GC fits the expected range.
 219      * Throws Fault if count is unexpected.
 220      *
 221      * @param count how many times GC has happened
 222      * @param min   expected minimum, if under zero - undefined
 223      * @param max   expected maximum, if under zero - undefined
 224      */
 225     void checkGCCount(int count, int min, int max) {
 226         if (min < 0) {
 227             if(count > max) {
 228                 throw new Fault("GC has happened too often: " + count + " times, " +
 229                         "expected count: less than " + max);
 230             }
 231         } else if (max < 0) {
 232             if(count < min) {
 233                 throw new Fault("GC has happened too rare: " + count + " times, " +


 170         System.out.println("% Committed metaspce: " + bytes2k(getCommitted()));
 171 
 172         cleanLoadedClasses();
 173 
 174         if (attempts == maxAttempts) {
 175             throw new Fault("Committed amount hasn't achieved " + bytes2k(committedLevel));
 176         }
 177 
 178         if (VMRuntimeEnvUtils.isVMOptionEnabled("UseConcMarkSweepGC")) {
 179             System.out.println("ConcMarkSweep is used, cannot count GC");
 180             return;
 181         }
 182 
 183         int gcCount = getMetaspaceGCCount();
 184         if (gcCount < 0) {
 185             // perhpas, it's better to silently pass here... Let's see.
 186             throw new Fault ("Unable to count full collections, could be an env issue");
 187         }
 188         System.out.println("% GC has been invoked: " + gcCount + " times");
 189 







 190         if (maxMetaspaceFreeRatio <= 1) {
 191             // min/max = 0/1  boundary value
 192             // GC should happen very often
 193             checkGCCount(gcCount, 20, -1);
 194         } else if (minMetaspaceFreeRatio >= 99) {
 195             // min/max = 99/100  boundary value
 196             // GC should happen very rare
 197             checkGCCount(gcCount, -1, 2);
 198         } else if (minMetaspaceFreeRatio >= 10  && maxMetaspaceFreeRatio <= 20) {
 199             // GC should happen quite often
 200             checkGCCount(gcCount, 3, 30);
 201         } else if (minMetaspaceFreeRatio >= 70  && maxMetaspaceFreeRatio <= 80) {
 202             // GC should happen quite often
 203             checkGCCount(gcCount, 1, 3);
 204         } else {
 205             // hard to estimate

 206         }
 207 
 208     }
 209     /**
 210      * Checks that count of GC fits the expected range.
 211      * Throws Fault if count is unexpected.
 212      *
 213      * @param count how many times GC has happened
 214      * @param min   expected minimum, if under zero - undefined
 215      * @param max   expected maximum, if under zero - undefined
 216      */
 217     void checkGCCount(int count, int min, int max) {
 218         if (min < 0) {
 219             if(count > max) {
 220                 throw new Fault("GC has happened too often: " + count + " times, " +
 221                         "expected count: less than " + max);
 222             }
 223         } else if (max < 0) {
 224             if(count < min) {
 225                 throw new Fault("GC has happened too rare: " + count + " times, " +
< prev index next >