Package com.tagtraum.perf.gcviewer.model

Examples of com.tagtraum.perf.gcviewer.model.GCEvent


        int maxX = clipBounds.x+clipBounds.width;

        int height = getHeight();
        int lastScaledTimestamp = Integer.MIN_VALUE;
        for (Iterator<GCEvent> i = getModelChart().getModel().getFullGCEvents(); i.hasNext();) {
            GCEvent event = i.next();
            int scaledTimestamp = (int)(scaleFactor * (event.getTimestamp() - getModelChart().getModel().getFirstPauseTimeStamp()));
            if (scaledTimestamp != lastScaledTimestamp && scaledTimestamp >= minX && scaledTimestamp <= maxX) {
                g2d.drawLine(scaledTimestamp, 0, scaledTimestamp, height);
                lastScaledTimestamp = scaledTimestamp;
            }
        }
View Full Code Here


    public void paintComponent(Graphics2D g2d) {
        double scaleFactor = getModelChart().getScaleFactor();
        int height = getHeight();
        int lastScaledTimestamp = Integer.MIN_VALUE;
        for (Iterator<GCEvent> i = getModelChart().getModel().getGCEvents(); i.hasNext();) {
            GCEvent event = i.next();
            if (event.isInc()) {
                int scaledTimestamp = (int) (scaleFactor * (event.getTimestamp() - getModelChart().getModel().getFirstPauseTimeStamp()));
                if (scaledTimestamp != lastScaledTimestamp) {
                    g2d.drawLine(scaledTimestamp, 0, scaledTimestamp, height);
                    lastScaledTimestamp = scaledTimestamp;
                }
            }
View Full Code Here

            if (LOG.isLoggable(Level.INFO)) LOG.info("Done reading.");
        }
    }

    protected AbstractGCEvent<GCEvent> parseLine(String line, ParseInformation pos) throws ParseException {
        AbstractGCEvent<GCEvent> event = new GCEvent();
        try {
            event.setTimestamp(count);
            count++;
            StringTokenizer st = new StringTokenizer(line, " ,->()K\r\n");
            String token = st.nextToken();
            if (token.equals("Full") && st.nextToken().equals("GC")) {
                event.setType(AbstractGCEvent.Type.FULL_GC);
            } else if (token.equals("Inc") && st.nextToken().equals("GC")) {
                event.setType(AbstractGCEvent.Type.INC_GC);
            } else if (token.equals("GC")) {
                event.setType(AbstractGCEvent.Type.GC);
            } else {
                throw new ParseException("Error parsing entry: " + line);
            }
            setMemoryAndPauses((GCEvent)event, line);
            // debug
View Full Code Here

        try {
            final GCModel model = new GCModel();
            model.setFormat(GCModel.Format.IBM_VERBOSE_GC);
            int state = 0;
            String line = null;
            GCEvent lastEvent = new GCEvent();
            GCEvent event = null;
            long basetime = 0;
            cycleStartGCFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss yyyy", Locale.US);
            while ((line = in.readLine()) != null) {
                final String trimmedLine = line.trim();
                if (!"".equals(trimmedLine) && !trimmedLine.startsWith("<GC: ") && !trimmedLine.startsWith("<")) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info("Malformed line (" + in.getLineNumber() + "): " + line);
                    state = 0;
                }
                switch (state) {
                    case 0:
                        if (line.indexOf("Allocation Failure.") != -1) {
                            event = new GCEvent();
                            event.setType(AbstractGCEvent.Type.FULL_GC);
                            event.setTimestamp(lastEvent.getTimestamp() + parseTimeSinceLastAF(line));
                            // stay in state 0
                            break;
                        }
                        else if (line.indexOf("GC cycle started") != -1) { // can apparently occur without AF
                            event = new GCEvent();
                            event.setType(AbstractGCEvent.Type.FULL_GC);
                            final long time = parseGCCycleStart(line);
                            if (basetime == 0) basetime = time;
                            event.setTimestamp((time - basetime)/1000.0d);
                            state++;
                            break;
                        } else if (line.indexOf("managing allocation failure, action=3") != -1) {
                            event = new GCEvent();
                            event.setType(AbstractGCEvent.Type.FULL_GC);
                            event.setTimestamp(lastEvent.getTimestamp() + lastEvent.getPause());
                            event.setPreUsed(parsePreUsedAFAction3(line));
                            event.setPostUsed(event.getPreUsed());
                            // default to last event's total
                            event.setTotal(lastEvent.getTotal());
                            state = 2;
                            break;
                        }
                        break;
                    case 1:
                        if (line.indexOf("freed") != -1 && line.indexOf("unloaded") == -1) {
                            event.setPreUsed(parsePreUsed(line));
                            event.setPostUsed(parsePostUsed(line));
                            event.setTotal(parseTotalAfterGC(line));
                            event.setPause(parsePause(line));
                            model.add(event);
                            lastEvent = event;
                            event = null;
                            state = 0;
                            break;
                        }
                        break;
                    case 2:
                        if (line.indexOf("expanded heap by ") != -1 || line.indexOf("expanded heap fully by ") != -1) {
                            event.setTotal(parseTotalAfterHeapExpansion(line));
                            state++;
                            break;
                        }
                        if (line.indexOf("completed in") == -1) break;
                    case 3:
                        if (line.indexOf("completed in ") != -1) {
                            event.setPause(parsePause(line) - lastEvent.getPause());
                            model.add(event);
                            lastEvent = event;
                            event = null;
                            state = 0;
                        }
View Full Code Here

            String qualifiedName) throws SAXException {

        if ("af".equals(qualifiedName)) {
            System.out.println("In AF endElement!");
            if (currentAF != null) {
                GCEvent event = new GCEvent();
                if (!"tenured".equals(currentAF.type)) {
                    LOG.warning("Unhandled AF type: " + currentAF.type);
                }
                if (!"global".equals(currentAF.gcType)) {
                    LOG.warning("Different GC type: " + currentAF.gcType);
                }
                else {
                    event.setType(AbstractGCEvent.Type.FULL_GC);
                }
                if (currentAF.initialTotalBytes != -1
                        && currentAF.initialFreeBytes != -1) {
                    event.setPreUsed(currentAF.getPreUsedInKb());
                }

                if (currentAF.afterTotalBytes != -1
                        && currentAF.afterFreeBytes != -1) {
                    event.setPostUsed(currentAF.getPostUsedInKb());
                }

                if (currentAF.afterTotalBytes != -1) {
                    event.setTotal(currentAF.getTotalInKb());
                }

                // event.setTimestamp(currentAF.timestamp.getTime());
                event.setTimestamp(currentAF.elapsedTime);

                if (currentAF.totalTime >= 0) {
                    event.setPause(currentAF.totalTime);
                }

                if (currentAF.afterSOATotalBytes != -1
                        && currentAF.afterSOAFreeBytes != -1
                        && currentAF.initialSOAFreeBytes != -1
                        && currentAF.initialSOATotalBytes != -1) {
                   
                    final GCEvent detailEvent = new GCEvent();
                    detailEvent.setTimestamp(currentAF.elapsedTime);
                    detailEvent.setType(AbstractGCEvent.Type.PS_YOUNG_GEN);
                    detailEvent.setTenuredDetail(true);
                    detailEvent.setPreUsed(currentAF.getPreUsedSoaInKb());
                    detailEvent.setPostUsed(currentAF.getPostUsedSoaInKb());
                    detailEvent.setTotal(currentAF.getTotalSoaInKb());
                    event.add(detailEvent);
                }

                if (currentAF.afterLOATotalBytes != -1
                        && currentAF.afterLOAFreeBytes != -1
                        && currentAF.initialLOAFreeBytes != -1
                        && currentAF.initialLOATotalBytes != -1) {
                   
                    final GCEvent detailEvent = new GCEvent();
                    detailEvent.setTimestamp(currentAF.elapsedTime);
                    detailEvent.setType(AbstractGCEvent.Type.PS_OLD_GEN);
                    detailEvent.setTenuredDetail(true);
                    detailEvent.setPreUsed(currentAF.getPreUsedLoaInKb());
                    detailEvent.setPostUsed(currentAF.getPostUsedLoaInKb());
                    detailEvent.setTotal(currentAF.getTotalLoaInKb());
                    event.add(detailEvent);
                }

                model.add(event);
                currentTenured = 0;
View Full Code Here

        boolean gcSummary = false;
        try {
            GCModel model = new GCModel();
            model.setFormat(GCModel.Format.SUN_X_LOG_GC);
            String line = null;
            GCEvent event = null;
            int nurserySize = -1;
            while ((line = in.readLine()) != null) {
                // Sample JRockit log entry types to be parsed:
                //
                // [INFO ][memory ] GC mode: Garbage collection optimized for throughput, strategy: Generational Parallel Mark & Sweep
                // [INFO ][memory ] Heap size: 8388608KB, maximal heap size: 8388608KB, nursery size: 4194304KB
                // [INFO ][memory ] <start>-<end>: <type>..
                // [INFO ][memory ] [OC#2] 34.287-34.351: OC 460781KB->214044KB (524288KB), 0.064 s, sum of pauses 5.580 ms, longest pause 4.693 ms.
               
                final int memoryIndex = line.indexOf(MEMORY_MARKER);
                if (memoryIndex == -1) {
                    if (LOG.isLoggable(Level.FINE)) LOG.fine("Ignoring line " + in.getLineNumber() + ". Missing \"[memory ]\" marker: " + line);
                    continue;
                }
                if (line.endsWith(MEMORY_MARKER)) {
                    continue;
                }
                final int startLog = memoryIndex + MEMORY_MARKER.length();               
                // Skip "[INFO ][memory ] "

                // print some special JRockit summary statements to the log.
                if (!gcSummary) {
                    gcSummary = line.endsWith("Memory usage report");
                }
                // Log any relevant memory usage reports at INFO level, rest as FINE
                if (gcSummary) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startLog));
                    continue;
                }
                else if (line.indexOf("Prefetch distance") != -1) {                   
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startLog));
                    continue;
                }
                else if (line.indexOf("GC mode") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startLog));
                    continue;
                }
                else if (line.indexOf("GC strategy") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startLog));
                    continue;
                }
                else if (line.indexOf("OutOfMemory") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.warning("GC log contains OutOfMemory error: " + line.substring(startLog));
                    continue;
                }               
                else if (line.substring(startLog).startsWith("<")) {
                    // ignore
                    if (LOG.isLoggable(Level.FINE)) LOG.fine(line.substring(startLog));
                    continue;
                }               
                else if (line.toLowerCase().indexOf("heap size:") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startLog));
                    final int nurserySizeStart = line.indexOf(NURSERY_SIZE);
                    final int nurserySizeEnd = line.indexOf('K', nurserySizeStart + NURSERY_SIZE.length());
                    if (nurserySizeStart != -1) {
                        nurserySize = Integer.parseInt(line.substring(nurserySizeStart + NURSERY_SIZE.length(), nurserySizeEnd));
                    }
                    continue;
                }
                else if ((line.indexOf("C#") == -1) || (line.indexOf("->") == -1)){
                    // No [YC#] or [OC#] logs which we are interested in
                    if (LOG.isLoggable(Level.FINE)) LOG.fine(line.substring(startLog));
                    continue;
                }
                       
                // Assume this is an actual GC log of interest. Look for time string, skip ahead of [OC#2]
                // [memory ] [OC#2] 34.287-34.351: OC 460781KB->214044KB (524288KB), 0.064 s, sum of pauses 5.580 ms, longest pause 4.693 ms.
                //   OR if timestamp logging enabled...
                // [memory ][Sat Oct 27 20:04:38 2012][23355] [OC#2]
                int startGCStats = line.indexOf("C#"); // skip to OC# or YC#
                // Example:
                final int startTimeIndex = line.indexOf(']', startGCStats) + 1; // go to end of "[OC#2]" in above example                                
               
                final int colon = line.indexOf(':', startTimeIndex);
                if (colon == -1) {
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("Malformed line (" + in.getLineNumber() + "). Missing colon after start time: " + line);
                    continue;
                }
               
                event = new GCEvent();
               
                //34.287-34.351: OC 460781KB->214044KB (524288KB), 0.064 s, sum of pauses 5.580 ms, longest pause 4.693 ms.               

                // set timestamp
                final String timestampString = line.substring(startTimeIndex, colon);
                final int minus = timestampString.indexOf('-');
                if (minus == -1) {
                    event.setTimestamp(NumberParser.parseDouble(timestampString));
                }
                else {
                    event.setTimestamp(NumberParser.parseDouble(timestampString.substring(0, minus)));
                }

                // set type
                final int typeStart = skipSpaces(colon+1, line);
                int typeEnd = typeStart;
                while (!Character.isDigit(line.charAt(++typeEnd))) {}
                final AbstractGCEvent.Type type = AbstractGCEvent.Type.lookup("jrockit." + line.substring(typeStart, typeEnd).trim());
                if (type == null) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info("Failed to determine type: " + line.substring(startTimeIndex));
                    continue;
                }
                event.setType(type);

                // Parse GC before/after sizes: "460781KB->214044KB (524288KB)"
                // before
                final int startBefore = typeEnd;
                final int endBefore = line.indexOf('K', startBefore);
                event.setPreUsed(Integer.parseInt(line.substring(startBefore, endBefore)));

                // after
                final int startAfter = endBefore+4;
                final int endAfter = line.indexOf('K', startAfter);
                event.setPostUsed(Integer.parseInt(line.substring(startAfter, endAfter)));

                // total
                final int startTotal = line.indexOf('(', endAfter) + 1;
                final int endTotal = line.indexOf('K', startTotal);
                event.setTotal(Integer.parseInt(line.substring(startTotal, endTotal)));

                // pause
                // 7786210KB->3242204KB (8388608KB), 0.911 s, sum of pauses 865.900 ms, longest pause 865.900 ms.
                final int startPause = line.indexOf(PAUSE_MARKER, endTotal) + PAUSE_MARKER.length();
                final int endPause = line.indexOf(' ', startPause);
                event.setPause(NumberParser.parseDouble(line.substring(startPause, endPause)) / 1000.0d);
                model.add(event);

                // add artificial detail events
                if (nurserySize != -1 && event.getExtendedType().getGeneration() == Generation.YOUNG) {
                    GCEvent detailEvent = new GCEvent();
                    detailEvent.setType(event.getExtendedType().getType());
                    detailEvent.setTimestamp(event.getTimestamp());
                    detailEvent.setTotal(nurserySize);
                    event.add(detailEvent);
                }
                if (nurserySize != -1 && event.getExtendedType().getGeneration() == Generation.TENURED) {
                    GCEvent detailEvent = new GCEvent();
                    detailEvent.setType(event.getExtendedType().getType());
                    detailEvent.setTimestamp(event.getTimestamp());
                    detailEvent.setTotal(event.getTotal() - nurserySize);
                    event.add(detailEvent);
                }
            }
            return model;
        } finally {
View Full Code Here

        if (LOG.isLoggable(Level.INFO)) LOG.info("Reading HP-UX 1.4.1-1.4.2 format...");
        try {
            final GCModel model = new GCModel();
            model.setFormat(GCModel.Format.SUN_X_LOG_GC);
            String line = null;
            GCEvent event = null;
            while ((line = in.readLine()) != null) {
                final StringTokenizer st = new StringTokenizer(line, " ");
                if (st.countTokens() != 22) {
                    if (LOG.isLoggable(Level.WARNING)) {
                        LOG.warning("Malformed line (" + in.getLineNumber() + "). Wrong number of tokens ("+st.countTokens()+"): " + line);
                        continue;
                    }
                }
                if (!"<GC:".equals(st.nextToken())) {
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("Malformed line (" + in.getLineNumber() + "). Expected \"<GC:\" in " + line);
                    continue;
                }
                event = new GCEvent();
                /*
                %1:  Indicates the type of the garbage collection.
                        1: represents a Scavenge (GC of New Generation only)
                           %2: indicates if this is a parallel scavenge.
                                0: non-parallel scavenge
                                n(>0): parallel scavenge, n represents the number of
                                       parallel GC threads

                        2: represents an Old Generation GC or a Full GC
                           %2: indicates the GC reason:
                                1: Allocation failure
                                2: Call to System.gc
                                3: Tenured Generation full
                                4: Permanent Generation full
                                5: Train Generation full
                                6: Concurrent-Mark-Sweep (CMS) Generation full
                                7: Old generation expanded on last scavenge
                                8: Old generation too full to scavenge
                                9: FullGCAlot
                               10: Allocation profiler triggered
                               11: Last ditch collection
                                   If the heap area holding the reflection objects (representing classes and methods) is
                                   full, VM first invokes permanent generation collection. If that fails, then it tries to
                                   expand permanent generation.
                           If that also fails, it invokes last ditch collection, to reclaim as much space as possible.

                               12: Heap dump triggered
                               13: gcLocker triggered
                               14: No cause specified

                               (Number 11: "Last ditch collection" is added since 1.4.2.03. Number 12, 13 and 14 are added since 1.4.2.10).

                        3: represents a complete background CMS GC
                           %2:  indicates the GC reason:
                                1: Occupancy > initiatingOccupancy
                                2: Expanded recently
                                3: Incremental collection will fail
                                4: Linear allocation will fail
                                5: Anticipated promotion

                        4: represents an incomplete background CMS GC
                              (exited after yielding to foreground GC)
                           %2:  n.m
                                n indicates the GC reason:
                                  1: Occupancy > initiatingOccupancy
                                  2: Expanded recently
                                  3: Incremental collection will fail
                                  4: Linear allocation will fail
                                  5: Anticipated promotion
                                m indicates the background CMS state when yielding:
                                  0: Resetting
                                  1: Idling
                                  2: InitialMarking
                                  3: Marking
                                  4: FinalMarking
                                  5: Precleaning
                                  6: Sweeping
                */
                final int typeOfGC = Integer.parseInt(st.nextToken());
                // %2:  see above
                final float gcDetails = Float.parseFloat(st.nextToken());
                event.setType(findType(typeOfGC, gcDetails));
                // %3:  Program time at the beginning of the collection, in seconds
                event.setTimestamp(NumberParser.parseDouble(st.nextToken()));
                // %4:  Garbage collection invocation. Counts of background CMS GCs
                // and other GCs are maintained separately
                st.nextToken();
                // %5:  Size of the object allocation request that forced the GC, in bytes
                st.nextToken();
                // %6:  Tenuring threshold - determines how long the new born object
                // remains in the New Generation
                st.nextToken();
                // Eden Sub-space (within the New Generation)
                // %7:  Before
                // %8:  After
                // %9:  Capacity
                final long edenBefore = Long.parseLong(st.nextToken());
                final long edenAfter = Long.parseLong(st.nextToken());
                final long edenCapacity = Long.parseLong(st.nextToken());
                /*
                GCEvent edenEvent = new GCEvent();
                edenEvent.setType(AbstractGCEvent.Type.DEF_NEW);
                edenEvent.setPreUsed((int)(edenBefore / 1024));
                edenEvent.setPostUsed((int)(edenAfter / 1024));
                edenEvent.setTotal((int)(edenCapacity / 1024));
                */

                // Survivor Sub-space (within the New Generation)
                // %10:   Before
                // %11:  After
                // %12:  Capacity
                final long survivorBefore = Long.parseLong(st.nextToken());
                final long survivorAfter = Long.parseLong(st.nextToken());
                final long survivorCapacity = Long.parseLong(st.nextToken());
                /*
                GCEvent survivorEvent = new GCEvent();
                survivorEvent.setType(AbstractGCEvent.Type.DEF_NEW);
                survivorEvent.setPreUsed((int)(survivorBefore / 1024));
                survivorEvent.setPostUsed((int)(survivorAfter / 1024));
                survivorEvent.setTotal((int)(survivorCapacity / 1024));
                */

                // Since we don't distinguish between survivor spaces and eden, we add things up.
                final GCEvent newEvent = new GCEvent();
                newEvent.setType(AbstractGCEvent.Type.DEF_NEW);
                newEvent.setPreUsed((int)((survivorBefore + edenBefore) / 1024));
                newEvent.setPostUsed((int)((survivorAfter + edenAfter) / 1024));
                newEvent.setTotal((int)((survivorCapacity + edenCapacity) / 1024));

                // Old Generation
                // %13:  Before
                // %14:  After
                // %15:  Capacity
                final long oldBefore = Long.parseLong(st.nextToken());
                final long oldAfter = Long.parseLong(st.nextToken());
                final long oldCapacity = Long.parseLong(st.nextToken());
                final GCEvent oldEvent = new GCEvent();
                oldEvent.setType(AbstractGCEvent.Type.TENURED);
                oldEvent.setPreUsed((int)(oldBefore / 1024));
                oldEvent.setPostUsed((int)(oldAfter / 1024));
                oldEvent.setTotal((int)(oldCapacity / 1024));

                // Permanent Generation (Storage of Reflective Objects)
                // %16:  Before
                // %17:  After
                // %18:  Capacity
                final long permBefore = Long.parseLong(st.nextToken());
                final long permAfter = Long.parseLong(st.nextToken());
                final long permCapacity = Long.parseLong(st.nextToken());
                final GCEvent permEvent = new GCEvent();
                permEvent.setType(AbstractGCEvent.Type.PERM);
                permEvent.setPreUsed((int)(permBefore / 1024));
                permEvent.setPostUsed((int)(permAfter / 1024));
                permEvent.setTotal((int)(permCapacity / 1024));

                // %19:  The total stop-the-world duration, in seconds.
                final double pause = NumberParser.parseDouble(st.nextToken());
                event.setPause(pause);
                // %20:  The total time used in collection, in seconds.
View Full Code Here

        boolean gcSummary = false;
        try {
            GCModel model = new GCModel();
            model.setFormat(GCModel.Format.SUN_X_LOG_GC);
            String line = null;
            GCEvent event = null;
            int nurserySize = -1;
            int startTimeIndex = 0;
            while ((line = in.readLine()) != null) {
                final int memoryIndex = line.indexOf(MEMORY_MARKER);
                if (memoryIndex == -1) {
                    if (LOG.isLoggable(Level.FINE)) LOG.fine("Ignoring line " + in.getLineNumber() + ". Missing \"[memory ]\" marker: " + line);
                    continue;
                }
                if (line.endsWith(MEMORY_MARKER)) {
                    continue;
                }
               
                if (startTimeIndex == 0) {
                    // Not yet initialized. We will initialize position based on this [memory ] log
                    startTimeIndex = memoryIndex + MEMORY_MARKER.length() + 1;
                    // GC start time index changes if verbosetimestamp used:
                    // [INFO ][memory ] 4.817-4.857: GC 1641728K->148365K (3145728K)
                    // [memory ][Thu Feb 21 15:08:25 2013][09368] 4.817-4.857: GC 1641728K->148365K (3145728K)
                    // skip to position of last "]" occuring after memory marker "[memory ]"
                    int verboseTimestampIndex = line.lastIndexOf(']', line.length());
                    if (verboseTimestampIndex > startTimeIndex) {
                        if (LOG.isLoggable(Level.FINE)) LOG.fine("Log entries have verbose timestamp");
                        startTimeIndex = verboseTimestampIndex + 2; // skip "] "
                    }                   
                }

                // print some special statements to the log.
                if (!gcSummary) {
                    gcSummary = line.endsWith("Memory usage report");
                }
                if (gcSummary) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("Prefetch distance") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("GC mode") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("GC strategy") != -1) {
                    //JRockit dynamically changes GC strategy if using gcPrio, ignore these
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("OutOfMemory") != -1) {
                    //If the application exits with OutOfMemory, it can get printed to GC log as well
                    //Log as SEVERE for user, but ignore for parsing
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("GC log contains OutOfMemory error: " + line.substring(startTimeIndex));
                    continue;
                }               
                else if (line.toLowerCase().indexOf("heap size:") != -1) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info(line.substring(startTimeIndex));
                    final int nurserySizeStart = line.indexOf(NURSERY_SIZE);
                    final int nurserySizeEnd = line.indexOf('K', nurserySizeStart + NURSERY_SIZE.length());
                    if (nurserySizeStart != -1) {
                        nurserySize = Integer.parseInt(line.substring(nurserySizeStart + NURSERY_SIZE.length(), nurserySizeEnd));
                    }
                    continue;
                }
                else if (line.substring(startTimeIndex).startsWith("<")) {
                    // ignore
                    if (LOG.isLoggable(Level.FINE)) LOG.fine(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("K->K") != -1){
                    // Ignore lines like this:
                    // -: GC K->K (K), ms
                    if (LOG.isLoggable(Level.FINE)) LOG.fine(line.substring(startTimeIndex));
                    continue;
                }
                else if (line.indexOf("->") == -1){
                    // Ignore anything that is not of the format:
                    // 1643328K->159027K (3145728K), 71.126 ms
                    // That is, no graph data means of no consequence
                    // Example: Thu Feb 21 15:09:22 2013][09368] Memory usage report
                    if (LOG.isLoggable(Level.FINE)) LOG.fine(line.substring(startTimeIndex));
                    continue;
                }               
        
                final int colon = line.indexOf(':', startTimeIndex);
                if (colon == -1) {
                    if (LOG.isLoggable(Level.WARNING)) LOG.warning("Malformed line (" + in.getLineNumber() + "). Missing colon after start time: " + line);
                    continue;
                }
                event = new GCEvent();

                // set timestamp
                final String timestampString = line.substring(startTimeIndex, colon);
                final int minus = timestampString.indexOf('-');
                if (minus == -1) {
                    event.setTimestamp(NumberParser.parseDouble(timestampString));
                }
                else {
                    event.setTimestamp(NumberParser.parseDouble(timestampString.substring(0, minus)));
                }

                // set type
                final int typeStart = skipSpaces(colon+1, line);
                int typeEnd = typeStart;
                while (!Character.isDigit(line.charAt(++typeEnd))) {}
                final AbstractGCEvent.Type type = AbstractGCEvent.Type.lookup("jrockit." + line.substring(typeStart, typeEnd).trim());
                if (type == null) {
                    if (LOG.isLoggable(Level.INFO)) LOG.info("Failed to determine type: " + line.substring(startTimeIndex));
                    continue;
                }
                event.setType(type);

                // before
                final int startBefore = typeEnd;
                final int endBefore = line.indexOf('K', startBefore);
                event.setPreUsed(Integer.parseInt(line.substring(startBefore, endBefore)));

                // after
                final int startAfter = endBefore+3;
                final int endAfter = line.indexOf('K', startAfter);
                event.setPostUsed(Integer.parseInt(line.substring(startAfter, endAfter)));

                // total
                final int startTotal = line.indexOf('(', endAfter) + 1;
                final int endTotal = line.indexOf('K', startTotal);
                event.setTotal(Integer.parseInt(line.substring(startTotal, endTotal)));

                // pause
                int startPause = line.indexOf(',', endTotal);
                while (!Character.isDigit(line.charAt(++startPause))) {}
                final int endPause = line.indexOf(' ', startPause);
                event.setPause(NumberParser.parseDouble(line.substring(startPause, endPause)) / 1000.0d);
                model.add(event);

                // add artificial detail events
                if (nurserySize != -1 && event.getExtendedType().getGeneration() == Generation.YOUNG) {
                    GCEvent detailEvent = new GCEvent();
                    detailEvent.setType(event.getExtendedType().getType());
                    detailEvent.setTimestamp(event.getTimestamp());
                    detailEvent.setTotal(nurserySize);
                    event.add(detailEvent);
                }
                if (nurserySize != -1 && event.getExtendedType().getGeneration() == Generation.TENURED) {
                    GCEvent detailEvent = new GCEvent();
                    detailEvent.setType(event.getExtendedType().getType());
                    detailEvent.setTimestamp(event.getTimestamp());
                    detailEvent.setTotal(event.getTotal() - nurserySize);
                    event.add(detailEvent);
                }
            }
            return model;
        } finally {
View Full Code Here

TOP

Related Classes of com.tagtraum.perf.gcviewer.model.GCEvent

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.