public MemoryMapDiffPane(UIState s, IViewPaneEventListener l, VisualElement toolbarExtension)
            : base(s, l)
        {
            CurrentTableView = (TableDisplayMode)UnityEditor.EditorPrefs.GetInt("Unity.MemoryProfiler.Editor.UI.MemoryMapPaneDiff.TableDisplayMode", (int)TableDisplayMode.Regions);

            m_ToolbarExtension = toolbarExtension;
            m_ToolbarExtensionPane = new IMGUIContainer(new Action(OnGUIToolbarExtension));

            s.CurrentMode.ViewPaneChanged += OnViewPaneChanged;
            s.ModeChanged += OnModeChanged;

            string[] displayElements = Enum.GetNames(typeof(MemoryMap.MemoryMapDiff.DisplayElements));
            m_DisplayElementsList = new GUIContent[displayElements.Length];
            for (int i = 0; i < displayElements.Length; ++i)
                m_DisplayElementsList[i] = new GUIContent(displayElements[i]);

            string[] colorSchemes = Enum.GetNames(typeof(MemoryMap.MemoryMapDiff.ColorScheme));
            m_ColorSchemeList = new GUIContent[colorSchemes.Length];
            for (int i = 0; i < colorSchemes.Length; ++i)
                m_ColorSchemeList[i] = new GUIContent(colorSchemes[i]);

            ulong maxSize = 256 * 1024 * 1024; // 256,128,  64,32,16,8,  4,2,1,512,  256,128,64,32
            m_BytesInRowList = new RowSize[14];
            for (int i = 0; i < m_BytesInRowList.Length; ++i)
                m_BytesInRowList[i] = new RowSize(maxSize >> i);

            UIState.SnapshotMode mode1 = m_UIState.FirstMode as UIState.SnapshotMode;
            UIState.SnapshotMode mode2 = m_UIState.SecondMode as UIState.SnapshotMode;
            m_ActiveMode = mode1;

            m_MemoryMap = new MemoryMap.MemoryMapDiff();
            m_MemoryMap.Setup(mode1.snapshot, mode2.snapshot);
            m_MemoryMap.RegionSelected += OnSelectRegions;
        }
        public override void OnClose()
        {
            m_MemoryMap.Dispose();
            m_MemoryMap = null;
            m_Spreadsheet = null;
            m_ActiveMode = null;

            if (m_ToolbarExtensionMode != null)
                m_ToolbarExtensionMode.ViewPaneChanged -= OnViewPaneChanged;
            m_ToolbarExtensionMode = null;
        }