@Override
 public void destroy() throws Exception {
   movingAverageStatistics.clear();
   admin.getVirtualMachines().getVirtualMachineRemoved().remove(this);
   admin.getVirtualMachines().getVirtualMachineStatisticsChanged().remove(this);
   admin.getVirtualMachines().stopStatisticsMonitor();
 }
  @Override
  public void virtualMachineRemoved(VirtualMachine virtualMachine) {

    movingAverageStatistics.clear(virtualMachine.getUid());

    final String groupUid = generateGroupUid(virtualMachine.getUid());
    Alert[] alertsByGroupUid =
        ((InternalAlertManager) admin.getAlertManager())
            .getAlertRepository()
            .getAlertsByGroupUid(groupUid);
    if (alertsByGroupUid.length != 0 && !alertsByGroupUid[0].getStatus().isResolved()) {
      AlertFactory factory = new AlertFactory();
      factory.name(ALERT_NAME);
      factory.groupUid(groupUid);
      factory.description(
          AlertBeanUtils.getGridComponentShortName(virtualMachine)
              + " Heap memory is unavailable; JVM has been removed");
      factory.severity(AlertSeverity.WARNING);
      factory.status(AlertStatus.NA);
      factory.componentUid(virtualMachine.getUid());
      factory.componentDescription(AlertBeanUtils.getGridComponentDescription(virtualMachine));
      factory.config(config.getProperties());

      Alert alert = factory.toAlert();
      admin.getAlertManager().triggerAlert(new HeapMemoryUtilizationAlert(alert));
    }
  }