void OnGUI()
        {
            Initialize();

            GUILayout.BeginHorizontal();
            if (GUILayout.Button("Take Snapshot", GUILayout.Width(100)))
            {
                UnityEditor.MemoryProfiler.MemorySnapshot.RequestNewSnapshot();
            }
            if (GUILayout.Button("Save Snapshot", GUILayout.Width(100)))
            {
                if (_snapshot != null)
                {
                    string fileName = EditorUtility.SaveFilePanel("Save Snapshot", null, "MemorySnapshot", "memsnap");
                    if (!string.IsNullOrEmpty(fileName))
                    {
                        System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                        using (Stream stream = File.Open(fileName, FileMode.Create))
                        {
                            bf.Serialize(stream, _snapshot);
                        }
                    }
                }
                else
                {
                    UnityEngine.Debug.LogWarning("No snapshot to save.  Try taking a snapshot first.");
                }
            }
            if (GUILayout.Button("Load Snapshot", GUILayout.Width(100)))
            {
                string fileName = EditorUtility.OpenFilePanel("Load Snapshot", null, "memsnap");
                if (!string.IsNullOrEmpty(fileName))
                {
                    System.Runtime.Serialization.Formatters.Binary.BinaryFormatter bf = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
                    using (Stream stream = File.Open(fileName, FileMode.Open))
                    {
                        IncomingSnapshot(bf.Deserialize(stream) as PackedMemorySnapshot);
                    }
                }
            }

            if (GUILayout.Button("Snap Diff Compare", GUILayout.Width(130)))
            {
                if (_snapshot_prev == null)
                {
                    Debug.LogError("Has not prev snap to compare..");
                    return;
                }
                MemorySnapDiffWindow.Create();
                MemorySnapDiffWindow.Instance.SetSnapshot(this);
            }

            if (_snapshot != null)
            {
                GUI.color = Color.red;
                EditorGUILayout.LabelField("CurrSnap " + _snap_time, GUILayout.Width(120));
                GUI.color = Color.white;
            }
            if (_snapshot_prev != null)
            {
                GUI.color = Color.red;
                EditorGUILayout.LabelField("PrevSnap " + _snap_prev_time, GUILayout.Width(120));
                GUI.color = Color.white;
            }
            GUILayout.EndHorizontal();

            if (_treeMapView != null)
            {
                _treeMapView.Draw();
            }
            if (_inspector != null)
            {
                _inspector.Draw();
            }

            //RenderDebugList();
        }
 public static void Create()
 {
     __instance = EditorWindow.GetWindow <MemorySnapDiffWindow>() as MemorySnapDiffWindow;
 }