private void updateState() {
      if (!isShowing()) {
        return;
      }
      AppMemoryUsage memoryUsage = calculateMemoryUsage();

      // convert to UI-friendly Mb:
      long heapMaxMb = toMb(memoryUsage.heapMaxBytes);
      long heapCommitedMb = toMb(memoryUsage.heapCommitedBytes);
      long heapUsedMb = toMb(memoryUsage.heapUsedBytes);

      long directBuffersUsedMb = toMb(memoryUsage.directByteBuffersBytes);
      long directBuffersFileCacheUsedMb = toMb(memoryUsage.directBuffersFileCacheUsedBytes);

      long jvmInternalsMb = toMb(memoryUsage.jvmInternalsMemoryBytes);
      long threadStacksMemoryMb = toMb(memoryUsage.threadStacksBytes);

      long memoryMappedFilesMb = toMb(memoryUsage.memoryMappedFilesBytes);

      long estimatedTotalMemoryUsedMb = toMb(memoryUsage.estimatedTotalMemoryUsedBytes());

      var text = Registry.is(SHOW_TOTAL_MEMORY_ESTIMATION_REGISTRY_KEY) ?
                 UIBundle.message("memory.usage.panel.message.text", heapUsedMb, estimatedTotalMemoryUsedMb) :
                 UIBundle.message("memory.usage.panel.message.text", heapUsedMb, heapMaxMb);

      if (heapCommitedMb != lastCommitedMb || heapUsedMb != lastUsedMb || !text.equals(getText())) {
        lastCommitedMb = heapCommitedMb;
        lastUsedMb = heapUsedMb;
        setText(text);

        boolean showExtendedInfoInTooTip = Registry.is(SHOW_MORE_INFO_IN_TOOLTIP_REGISTRY_KEY);
        String i18nBundleKey = showExtendedInfoInTooTip ?
                               "memory.usage.panel.message.tooltip-extended" :
                               "memory.usage.panel.message.tooltip";
        setToolTipText(
          UIBundle.message(i18nBundleKey,

                           heapUsedMb, heapCommitedMb, heapMaxMb,

                           directBuffersFileCacheUsedMb, (directBuffersUsedMb - directBuffersFileCacheUsedMb),

                           jvmInternalsMb, threadStacksMemoryMb,

                           estimatedTotalMemoryUsedMb,

                           memoryMappedFilesMb //shown only in .tooltip-extended version
          ));
      }
    }
private void updateState()