< prev index next >

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

Print this page




 163         System.gc();
 164         try {
 165             Thread.currentThread().sleep(500);
 166         } catch (Exception whatever) {
 167         }
 168     }
 169 
 170     /**
 171      * Reads gc.log file and returns it as a list of lines.
 172      * It's supposed that the test is executed with -Xlog:gc:gc.log option.
 173      *
 174      * @return List of strings the gc.log file is comprised.
 175      * @throws IOException if problem occurred while reading.
 176      */
 177     protected List<String> readGCLog() throws IOException {
 178         return Files.readAllLines(Paths.get(".", gclogFileName));
 179     }
 180 
 181     /**
 182      * Reads gc.log file and counts GC induced by metaspace.
 183      * Note: this method doesn't work for ConcMarkSweep...
 184      * @return how many times GC induced by metaspace has occurred.
 185      */
 186     protected int getMetaspaceGCCount() {
 187         int count = 0;
 188         try {
 189             for (String line: readGCLog()) {
 190                 if (line.indexOf("Pause Full") > 0 && line.indexOf("Meta") > 0) {
 191                     count++;
 192                 }
 193             }
 194             return count;
 195         } catch (Throwable t) {
 196             t.printStackTrace(System.err);
 197             return -1;
 198         }
 199     }
 200 
 201     protected String lastGCLogLine() {
 202         if (gclogFileName == null) {
 203             return "";
 204         }
 205         try {
 206             List<String> list = Files.readAllLines(Paths.get(".", gclogFileName));
 207             return list.get(list.size() - 1);
 208         } catch (IOException e) {
 209             return "File not found";
 210         }




 163         System.gc();
 164         try {
 165             Thread.currentThread().sleep(500);
 166         } catch (Exception whatever) {
 167         }
 168     }
 169 
 170     /**
 171      * Reads gc.log file and returns it as a list of lines.
 172      * It's supposed that the test is executed with -Xlog:gc:gc.log option.
 173      *
 174      * @return List of strings the gc.log file is comprised.
 175      * @throws IOException if problem occurred while reading.
 176      */
 177     protected List<String> readGCLog() throws IOException {
 178         return Files.readAllLines(Paths.get(".", gclogFileName));
 179     }
 180 
 181     /**
 182      * Reads gc.log file and counts GC induced by metaspace.

 183      * @return how many times GC induced by metaspace has occurred.
 184      */
 185     protected int getMetaspaceGCCount() {
 186         int count = 0;
 187         try {
 188             for (String line: readGCLog()) {
 189                 if (line.indexOf("Metadata GC ") > 0) {
 190                     count++;
 191                 }
 192             }
 193             return count;
 194         } catch (Throwable t) {
 195             t.printStackTrace(System.err);
 196             return -1;
 197         }
 198     }
 199 
 200     protected String lastGCLogLine() {
 201         if (gclogFileName == null) {
 202             return "";
 203         }
 204         try {
 205             List<String> list = Files.readAllLines(Paths.get(".", gclogFileName));
 206             return list.get(list.size() - 1);
 207         } catch (IOException e) {
 208             return "File not found";
 209         }


< prev index next >