@Override
 public void testRunStarted(final Description description) throws Exception {
   if (!HybrisJUnit4Test.intenseChecksActivated()) {
     return;
   }
   currentTestClass = description.getDisplayName();
   heapAtTestStart = memoryBean.getHeapMemoryUsage();
   nonHeapAtTestStart = memoryBean.getNonHeapMemoryUsage();
 }
  @Override
  public void testRunFinished(final Result result) throws Exception {
    if (!HybrisJUnit4Test.intenseChecksActivated()) {
      return;
    }

    final MemoryUsage heapAtTestEnd = memoryBean.getHeapMemoryUsage();
    final MemoryUsage nonHeapAtTestEnd = memoryBean.getNonHeapMemoryUsage();

    final long initHeapDiffInK = (heapAtTestEnd.getInit() - heapAtTestStart.getInit()) / 1024;
    final long usedHeapDiffInK = (heapAtTestEnd.getUsed() - heapAtTestStart.getUsed()) / 1024;
    final long comittedHeapDiffInK =
        (heapAtTestEnd.getCommitted() - heapAtTestStart.getCommitted()) / 1024;

    final long initNonHeapDiffInK =
        (nonHeapAtTestEnd.getInit() - nonHeapAtTestStart.getInit()) / 1024;
    final long usedNonHeapDiffInK =
        (nonHeapAtTestEnd.getUsed() - nonHeapAtTestStart.getUsed()) / 1024;
    final long comittedNonHeapDiffInK =
        (nonHeapAtTestEnd.getCommitted() - nonHeapAtTestStart.getCommitted()) / 1024;

    LOG.info("+---------------------------- Memory usage after test " + currentTestClass);
    LOG.info(
        "+     heap: init="
            + (heapAtTestEnd.getInit() / 1024)
            + "K ("
            + initHeapDiffInK
            + "K)\t  "
            + //
            "used="
            + (heapAtTestEnd.getUsed() / 1024)
            + "K ("
            + usedHeapDiffInK
            + "K)\t  "
            + //
            "comitted="
            + (heapAtTestEnd.getCommitted() / 1024)
            + "K ("
            + comittedHeapDiffInK
            + "K)");

    LOG.info(
        "+ non-heap: init="
            + (nonHeapAtTestEnd.getInit() / 1024)
            + "K ("
            + initNonHeapDiffInK
            + "K)\t  "
            + //
            "used="
            + (nonHeapAtTestEnd.getUsed() / 1024)
            + "K ("
            + usedNonHeapDiffInK
            + "K)\t  "
            + //
            "comitted="
            + (nonHeapAtTestEnd.getCommitted() / 1024)
            + "K ("
            + comittedNonHeapDiffInK
            + "K)");
    LOG.info("+ ObjectPendingFinalizationCount: " + memoryBean.getObjectPendingFinalizationCount());
    for (final MemoryPoolMXBean mpbean : ManagementFactory.getMemoryPoolMXBeans()) {
      LOG.info(
          "+       "
              + mpbean.getName()
              + "("
              + mpbean.getType()
              + "): "
              + mpbean.getCollectionUsage());
    }
    LOG.info(
        "+--------------------------------------------------------------------------------------------------");
  }