当前位置: 首页>>代码示例>>Java>>正文


Java GcInfo类代码示例

本文整理汇总了Java中com.sun.management.GcInfo的典型用法代码示例。如果您正苦于以下问题:Java GcInfo类的具体用法?Java GcInfo怎么用?Java GcInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


GcInfo类属于com.sun.management包,在下文中一共展示了GcInfo类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createGCNotification

import com.sun.management.GcInfo; //导入依赖的package包/类
void createGCNotification(long timestamp,
                          String gcName,
                          String gcAction,
                          String gcCause,
                          GcInfo gcInfo)  {

    if (!hasListeners()) {
        return;
    }

    Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
                                          getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          gcName);
    GarbageCollectionNotificationInfo info =
        new GarbageCollectionNotificationInfo(gcName,
                                              gcAction,
                                              gcCause,
                                              gcInfo);

    CompositeData cd =
        GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    sendNotification(notif);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:27,代码来源:GarbageCollectorImpl.java

示例2: printGcInfo

import com.sun.management.GcInfo; //导入依赖的package包/类
private static void printGcInfo(CompositeData cd) throws Exception {
    GcInfo info = GcInfo.from(cd);
    System.out.print("GC #" + info.getId());
    System.out.print(" start:" + info.getStartTime());
    System.out.print(" end:" + info.getEndTime());
    System.out.println(" (" + info.getDuration() + "ms)");
    Map<String,MemoryUsage> usage = info.getMemoryUsageBeforeGc();

    for (Map.Entry<String,MemoryUsage> entry : usage.entrySet()) {
        String poolname = entry.getKey();
        MemoryUsage busage = entry.getValue();
        MemoryUsage ausage = info.getMemoryUsageAfterGc().get(poolname);
        if (ausage == null) {
            throw new RuntimeException("After Gc Memory does not exist" +
                " for " + poolname);
        }
        System.out.println("Usage for pool " + poolname);
        System.out.println("   Before GC: " + busage);
        System.out.println("   After GC: " + ausage);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:ValidateOpenTypes.java

示例3: printGcInfo

import com.sun.management.GcInfo; //导入依赖的package包/类
private static void printGcInfo(GcInfo info) throws Exception {
    System.out.print("GC #" + info.getId());
    System.out.print(" start:" + info.getStartTime());
    System.out.print(" end:" + info.getEndTime());
    System.out.println(" (" + info.getDuration() + "ms)");
    Map<String,MemoryUsage> usage = info.getMemoryUsageBeforeGc();

    for (Map.Entry<String,MemoryUsage> entry : usage.entrySet()) {
        String poolname = entry.getKey();
        MemoryUsage busage = entry.getValue();
        MemoryUsage ausage = info.getMemoryUsageAfterGc().get(poolname);
        if (ausage == null) {
            throw new RuntimeException("After Gc Memory does not exist" +
                " for " + poolname);
        }
        System.out.println("Usage for pool " + poolname);
        System.out.println("   Before GC: " + busage);
        System.out.println("   After GC: " + ausage);
    }
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:21,代码来源:ProxyTypeMapping.java

示例4: createGCNotification

import com.sun.management.GcInfo; //导入依赖的package包/类
protected void createGCNotification(long timestamp,
                          String gcName,
                          String gcAction,
                          String gcCause,
                          GcInfo gcInfo)  {
    if (!hasListeners()) {
        return;
    }
    Notification notif = new Notification(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION,
                                          getObjectName(),
                                          getNextSeqNumber(),
                                          timestamp,
                                          gcName);
    GarbageCollectionNotificationInfo info =
        new GarbageCollectionNotificationInfo(gcName,
                                              gcAction,
                                              gcCause,
                                              gcInfo);

    CompositeData cd =
        GarbageCollectionNotifInfoCompositeData.toCompositeData(info);
    notif.setUserData(cd);
    sendNotification(notif);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:25,代码来源:GarbageCollectorExtImpl.java

示例5: handleNotification

import com.sun.management.GcInfo; //导入依赖的package包/类
@Override
public void handleNotification(Notification notification, Object handback) {
    if (notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION)) {
        System.out.println("0XDEADBEAF");
        GarbageCollectionNotificationInfo notifInfo = GarbageCollectionNotificationInfo.from((CompositeData) notification.getUserData());

        GcInfo gcInfo = notifInfo.getGcInfo();
        System.out.printf("Action: %s, %s, %s\n", notifInfo.getGcAction(), notifInfo.getGcCause(), notifInfo.getGcName());
        System.out.printf("Time: %d, %d, %d\n", gcInfo.getStartTime(), gcInfo.getEndTime(), gcInfo.getDuration());
        System.out.printf("Memory: %s, %s\n", gcInfo.getMemoryUsageBeforeGc().toString(), gcInfo.getMemoryUsageAfterGc().toString());



        Map<String, MemoryUsage> memBefore = notifInfo.getGcInfo().getMemoryUsageBeforeGc();
        Map<String, MemoryUsage> memAfter = notifInfo.getGcInfo().getMemoryUsageAfterGc();
        StringBuilder sb = new StringBuilder();
        sb.append("[").append(notifInfo.getGcAction()).append(" / ").append(notifInfo.getGcCause())
                .append(" / ").append(notifInfo.getGcName()).append(" / (");
        appendMemUsage(sb, memBefore);
        sb.append(") -> (");
        appendMemUsage(sb, memAfter);
        sb.append("), ").append(notifInfo.getGcInfo().getDuration()).append(" ms]");
        System.out.println(sb.toString());
    }
}
 
开发者ID:vitaly-chibrikov,项目名称:otus_java_2017_10,代码行数:26,代码来源:MemoryUtil.java

示例6: handleNotification

import com.sun.management.GcInfo; //导入依赖的package包/类
@Override
public void handleNotification(Notification notification, Object handback) {
    try {
        // Make sure it's the right notification type
        if (!notification.getType().equals(GarbageCollectionNotificationInfo.GARBAGE_COLLECTION_NOTIFICATION))
            return;

        // Extract the GcInfo as appropriate, working around the OpenJDK
        // GcInfo cycles/milliseconds bug
        GarbageCollectorMXBean bean = (GarbageCollectorMXBean) handback;
        GarbageCollectionNotificationInfo info = getInfo(notification);
        GcInfo gc = getGcInfo(info, bean);

        // Call the callback
        this.callback.onGC(gc);
    } catch (Exception e) {
        // swallow
    }
}
 
开发者ID:brownsys,项目名称:tracing-framework,代码行数:20,代码来源:XTraceGCUtils.java

示例7: registerGcMetrics

import com.sun.management.GcInfo; //导入依赖的package包/类
private static void registerGcMetrics(Map<String, Metric> metrics, long jvmStartTime, GarbageCollectorMXBean gcMxBean) {
    String gcName = gcMxBean.getName(), gcMetricNamePrefix = buildMetricName(GC_METRIC_NAME_PART, normalizeMetricDisplayName(gcName)),
        gcCollMetricNamePrefix = buildMetricName(gcMetricNamePrefix, COLLECTION_METRIC_NAME_PART);

    registerGauge(metrics, buildMetricName(gcMetricNamePrefix, NAME_METRIC_NAME_PART), gcName);
    registerGauge(metrics, buildMetricName(gcCollMetricNamePrefix, COUNT_METRIC_NAME_PART), gcMxBean.getCollectionCount());
    registerGauge(metrics, buildMetricName(gcCollMetricNamePrefix, TIME_METRIC_NAME_PART), gcMxBean.getCollectionTime());

    GcInfo gcInfo = gcMxBean.getLastGcInfo();

    if (gcInfo == null) {
        return;
    }

    String gcCollLastMetricNamePrefix = buildMetricName(gcCollMetricNamePrefix, LAST_METRIC_NAME_PART);

    registerGauge(metrics, buildMetricName(gcCollLastMetricNamePrefix, ID_METRIC_NAME_PART), gcInfo.getId());
    registerGauge(metrics, buildMetricName(gcCollLastMetricNamePrefix, TIME_START_METRIC_NAME_PREFIX), new Date((jvmStartTime + gcInfo.getStartTime())));
    registerGauge(metrics, buildMetricName(gcCollLastMetricNamePrefix, TIME_END_METRIC_NAME_PREFIX), new Date((jvmStartTime + gcInfo.getEndTime())));
    registerGauge(metrics, buildMetricName(gcCollLastMetricNamePrefix, DURATION_METRIC_NAME_PART), gcInfo.getDuration());

    registerGcMemoryUsageMetrics(metrics, buildMetricName(gcCollLastMetricNamePrefix, BEFORE_MEMORY_METRIC_NAME_PREFIX), gcInfo.getMemoryUsageBeforeGc());
    registerGcMemoryUsageMetrics(metrics, buildMetricName(gcCollLastMetricNamePrefix, AFTER_MEMORY_METRIC_NAME_PREFIX), gcInfo.getMemoryUsageAfterGc());
}
 
开发者ID:esacinc,项目名称:sdcct,代码行数:25,代码来源:GarbageCollectionMetricSet.java


注:本文中的com.sun.management.GcInfo类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。