private long computeFinalizers(Heap heap) {
   JavaClass finalizerClass = heap.getJavaClassByName("java.lang.ref.Finalizer"); // NOI18N
   if (finalizerClass != null) {
     Instance queue = (Instance) finalizerClass.getValueOfStaticField("queue"); // NOI18N
     if (queue != null) {
       Long len = (Long) queue.getValueOfField("queueLength"); // NOI18N
       if (len != null) {
         return len.longValue();
       }
     }
   }
   return -1;
 }
  private String printInstance(Instance in) {
    String className;
    JavaClass jcls = in.getJavaClass();

    if (jcls == null) {
      return "unknown instance #" + in.getInstanceId(); // NOI18N
    }
    if (jcls.equals(getJavaClass())) {
      JavaClass javaClass =
          heapFragmentWalker.getHeapFragment().getJavaClassByID(in.getInstanceId());

      if (javaClass != null) {
        className = javaClass.getName();
        return "<a href='"
            + CLASS_URL_PREFIX
            + className
            + "/"
            + javaClass.getJavaClassId()
            + "'>class "
            + className
            + "</a>"; // NOI18N
      }
    }
    className = jcls.getName();
    return "<a href='"
        + INSTANCE_URL_PREFIX
        + className
        + "/"
        + in.getInstanceNumber()
        + "/"
        + in.getInstanceId()
        + "' name='"
        + in.getInstanceId()
        + "'>"
        + className
        + '#'
        + in.getInstanceNumber()
        + "</a>"; // NOI18N
  }
  public String computeSummary() {
    File file = heapFragmentWalker.getHeapDumpFile();
    Heap heap = heapFragmentWalker.getHeapFragment();
    HeapSummary hsummary = heap.getSummary();
    long finalizers = computeFinalizers(heap);
    int nclassloaders = 0;
    JavaClass cl = heap.getJavaClassByName("java.lang.ClassLoader"); // NOI18N
    NumberFormat numberFormat = (NumberFormat) NumberFormat.getInstance().clone();
    numberFormat.setMaximumFractionDigits(1);

    oome = getOOMEThread(heap);
    if (cl != null) {
      nclassloaders = cl.getInstancesCount();

      Collection<JavaClass> jcs = cl.getSubClasses();

      for (JavaClass jc : jcs) {
        nclassloaders += jc.getInstancesCount();
      }
    }

    String filename =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_FileItemString(
                file != null && file.exists()
                    ? file.getAbsolutePath()
                    : Bundle.OverviewController_NotAvailableMsg());

    String filesize =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_FileSizeItemString(
                file != null && file.exists()
                    ? numberFormat.format(file.length() / (1024 * 1024.0)) + " MB"
                    : // NOI18N
                    Bundle.OverviewController_NotAvailableMsg());

    String dateTaken =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_DateTakenItemString(
                new Date(hsummary.getTime()).toString());

    String liveBytes =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_TotalBytesItemString(
                numberFormat.format(hsummary.getTotalLiveBytes()));

    String liveClasses =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_TotalClassesItemString(
                numberFormat.format(heap.getAllClasses().size()));

    String liveInstances =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_TotalInstancesItemString(
                numberFormat.format(hsummary.getTotalLiveInstances()));

    String classloaders =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_ClassloadersItemString(numberFormat.format(nclassloaders));

    String gcroots =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_GcRootsItemString(
                numberFormat.format(heap.getGCRoots().size()));

    String finalizersInfo =
        "&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
            + Bundle.OverviewController_FinalizersItemString(numberFormat.format(finalizers));

    String oomeString = "";
    if (oome != null) {
      Instance thread = oome.getInstance();
      String threadName = htmlize(getThreadName(thread));
      String threadUrl =
          "<a href='"
              + THREAD_URL_PREFIX
              + thread.getJavaClass().getName()
              + "/"
              + thread.getInstanceId()
              + "'>"
              + threadName
              + "</a>"; // NOI18N
      oomeString =
          "<br><br>&nbsp;&nbsp;&nbsp;&nbsp;" // NOI18N
              + Bundle.OverviewController_OOMELabelString()
              + "<br>&nbsp;&nbsp;&nbsp;&nbsp;"
              + Bundle.OverviewController_OOMEItemString(threadUrl);
    }
    String memoryRes = Icons.getResource(ProfilerIcons.HEAP_DUMP);
    return "<b><img border='0' align='bottom' src='nbresloc:/"
        + memoryRes
        + "'>&nbsp;&nbsp;" // NOI18N
        + Bundle.OverviewController_SummaryString()
        + "</b><br><hr>"
        + dateTaken
        + "<br>"
        + filename
        + "<br>"
        + filesize
        + "<br><br>"
        + liveBytes // NOI18N
        + "<br>"
        + liveClasses
        + "<br>"
        + liveInstances
        + "<br>"
        + classloaders
        + "<br>"
        + gcroots
        + "<br>"
        + finalizersInfo
        + oomeString; // NOI18N
  }