@Override
    public void paintComponent(Graphics g) {
      Dimension size = getSize();
      int barWidth = size.width;


      long usedMem;
      long allocatedMem;
      long maxMem;
      if (Registry.is(SHOW_TOTAL_MEMORY_ESTIMATION_REGISTRY_KEY)) {
        // [ heap used | heap commited | total (approx.) commited ]
        AppMemoryUsage memoryUsage = calculateMemoryUsage();
        maxMem = toMb(memoryUsage.estimatedTotalMemoryUsedBytes());
        allocatedMem = toMb(memoryUsage.heapCommitedBytes);
        usedMem = toMb(memoryUsage.heapUsedBytes);
      }
      else {
        // [ heap used | heap commited | heap max ]
        // use old-school heap accessor:
        Runtime runtime = Runtime.getRuntime();

        maxMem = runtime.maxMemory();
        allocatedMem = runtime.totalMemory();
        usedMem = allocatedMem - runtime.freeMemory();
      }

      int usedBarLength = (int)(barWidth * usedMem / maxMem);
      int allocatedBarLength = (int)(barWidth * allocatedMem / maxMem);

      // background
      g.setColor(UIUtil.getPanelBackground());
      g.fillRect(0, 0, barWidth, size.height);

      // gauge (allocated)
      g.setColor(myUnusedColor);
      g.fillRect(0, 0, allocatedBarLength, size.height);

      // gauge (used)
      g.setColor(myUsedColor);
      g.fillRect(0, 0, usedBarLength, size.height);

      //text
      super.paintComponent(g);
    }
@Override
    public void paintComponent(Graphics g)