@Override
  public void init(IViewSite site) throws PartInitException {
    super.init(site);

    fViewCnt++;
    String secondaryId = site.getSecondaryId();
    if (secondaryId != null) MemoryViewIdRegistry.registerView(secondaryId);

    // only do this the first time
    // not sure if there is a bug in the UI... if the view is
    // not a primary view and if it's hidden, the view is not
    // init and created until it becomes visible.
    if (fViewCnt == 1) {
      // also try to find other views and register
      if (DebugUIPlugin.getActiveWorkbenchWindow() != null
          && DebugUIPlugin.getActiveWorkbenchWindow().getActivePage() != null) {
        IViewReference references[] =
            DebugUIPlugin.getActiveWorkbenchWindow().getActivePage().getViewReferences();
        for (int i = 0; i < references.length; i++) {
          if (references[i].getSecondaryId() != null) {
            MemoryViewIdRegistry.registerView(references[i].getSecondaryId());
          }
        }
      }
    }

    fSyncService = new MemoryViewSynchronizationService();
  }
  @Override
  public void dispose() {
    getSite().getPage().removePartListener(fPartListener);

    Enumeration<IMemoryViewPane> enumeration = fViewPanes.elements();
    while (enumeration.hasMoreElements()) {
      Object element = enumeration.nextElement();
      if (element instanceof IMemoryViewPane) {
        ((IMemoryViewPane) element).dispose();
      }
    }

    fViewPaneControls.clear();

    IViewSite viewSite = getViewSite();
    String secondaryId = viewSite.getSecondaryId();
    if (secondaryId != null) MemoryViewIdRegistry.deregisterView(secondaryId);

    fSyncService.shutdown();

    if (fAddHandler != null) fAddHandler.dispose();

    if (fToggleMonitorsHandler != null) fToggleMonitorsHandler.dispose();

    if (fNextMemoryBlockHandler != null) fNextMemoryBlockHandler.dispose();

    super.dispose();
  }