public MemoryProfilerModuleViewController(ProfilerWindow profilerWindow, MemoryProfilerModule memoryModule) : base(profilerWindow)
 {
     profilerWindow.SelectedFrameIndexChanged += UpdateContent;
     m_MemoryModule = memoryModule;
     if (!m_MemoryModule.InitiateMemoryProfilerPackageAvailabilityCheck())
     {
         m_InitiatedPackageSearchQuery = true;
     }
 }
            void UpdateContent(long frame)
            {
                if (m_MemoryModule.m_ShowDetailedMemoryPane != ProfilerMemoryView.Simple)
                {
                    return;
                }
                var dataAvailable = CheckMemoryStatsAvailablity(frame);

                if (m_AddedSimpleDataView != dataAvailable)
                {
                    // refresh the view structure
                    ViewChanged(ProfilerMemoryView.Simple);
                    return;
                }
                if (!dataAvailable)
                {
                    return;
                }
                if (m_UIState != null)
                {
                    using (var data = ProfilerDriver.GetRawFrameDataView((int)frame, 0))
                    {
                        m_SimplePaneStringBuilder.Clear();
                        if (data.valid && data.GetMarkerId("Total Reserved Memory") != FrameDataView.invalidMarkerId)
                        {
                            var systemUsedMemoryId = data.GetMarkerId("System Used Memory");

                            var systemUsedMemory = (ulong)data.GetCounterValueAsLong(systemUsedMemoryId);

                            var systemUsedMemoryIsKnown = (systemUsedMemoryId != FrameDataView.invalidMarkerId && systemUsedMemory > 0);

                            var maxSystemUsedMemory = m_MaxSystemUsedMemory = systemUsedMemory;
                            if (!m_MemoryModule.m_Normalized)
                            {
                                UpdateMaxSystemUsedMemory(ProfilerWindow.firstAvailableFrameIndex, ProfilerWindow.lastAvailableFrameIndex);
                                maxSystemUsedMemory = m_MaxSystemUsedMemory;
                            }

                            var totalUsedId     = data.GetMarkerId("Total Used Memory");
                            var totalUsed       = (ulong)data.GetCounterValueAsLong(totalUsedId);
                            var totalReservedId = data.GetMarkerId("Total Reserved Memory");
                            var totalReserved   = (ulong)data.GetCounterValueAsLong(totalReservedId);

                            m_TotalUsed[0]     = totalUsed;
                            m_TotalReserved[0] = totalReserved;

                            if (!systemUsedMemoryIsKnown)
                            {
                                systemUsedMemory = totalReserved;
                            }

                            m_UIState.TopLevelBreakdown.SetVaules(systemUsedMemory, m_TotalReserved, m_TotalUsed, m_MemoryModule.m_Normalized, maxSystemUsedMemory, systemUsedMemoryIsKnown);

                            m_Used[4]     = totalUsed;
                            m_Reserved[4] = totalReserved;

                            var gfxReservedId = data.GetMarkerId("Gfx Reserved Memory");
                            m_Reserved[1] = m_Used[1] = (ulong)data.GetCounterValueAsLong(gfxReservedId);

                            var managedUsedId = data.GetMarkerId("GC Used Memory");
                            m_Used[0] = (ulong)data.GetCounterValueAsLong(managedUsedId);
                            var managedReservedId = data.GetMarkerId("GC Reserved Memory");
                            m_Reserved[0] = (ulong)data.GetCounterValueAsLong(managedReservedId);

                            var audioReservedId = data.GetMarkerId("Audio Used Memory");
                            m_Reserved[2] = m_Used[2] = (ulong)data.GetCounterValueAsLong(audioReservedId);

                            var videoReservedId = data.GetMarkerId("Video Used Memory");
                            m_Reserved[3] = m_Used[3] = (ulong)data.GetCounterValueAsLong(videoReservedId);


                            var profilerUsedId = data.GetMarkerId("Profiler Used Memory");
                            m_Used[5] = (ulong)data.GetCounterValueAsLong(profilerUsedId);
                            var profilerReservedId = data.GetMarkerId("Profiler Reserved Memory");
                            m_Reserved[5] = (ulong)data.GetCounterValueAsLong(profilerReservedId);

                            m_Used[4]     -= Math.Min(m_Used[0] + m_Used[1] + m_Used[2] + m_Used[3] + m_Used[5], m_Used[4]);
                            m_Reserved[4] -= Math.Min(m_Reserved[0] + m_Reserved[1] + m_Reserved[2] + m_Reserved[3] + m_Reserved[5], m_Reserved[4]);
                            m_UIState.Breakdown.SetVaules(systemUsedMemory, m_Reserved, m_Used, m_MemoryModule.m_Normalized, maxSystemUsedMemory, systemUsedMemoryIsKnown);

                            UpdateObjectRow(data, ref m_UIState.TexturesRow, "Texture Count", "Texture Memory");
                            UpdateObjectRow(data, ref m_UIState.MeshesRow, "Mesh Count", "Mesh Memory");
                            UpdateObjectRow(data, ref m_UIState.MaterialsRow, "Material Count", "Material Memory");
                            UpdateObjectRow(data, ref m_UIState.AnimationClipsRow, "AnimationClip Count", "AnimationClip Memory");
                            UpdateObjectRow(data, ref m_UIState.AssetsRow, "Asset Count");
                            UpdateObjectRow(data, ref m_UIState.GameObjectsRow, "Game Object Count");
                            UpdateObjectRow(data, ref m_UIState.SceneObjectsRow, "Scene Object Count");

                            UpdateObjectRow(data, ref m_UIState.GCAllocRow, "GC Allocation In Frame Count", "GC Allocated In Frame");

                            if (!m_UIState.CounterBasedUI.visible)
                            {
                                UIElementsHelper.SetVisibility(m_UIState.CounterBasedUI, true);
                            }

                            var platformSpecifics = MemoryProfilerModule.GetPlatformSpecificText(data, ProfilerWindow);
                            if (!string.IsNullOrEmpty(platformSpecifics))
                            {
                                m_SimplePaneStringBuilder.Append(platformSpecifics);
                            }
                        }
                        else
                        {
                            if (m_UIState.CounterBasedUI.visible)
                            {
                                UIElementsHelper.SetVisibility(m_UIState.CounterBasedUI, false);
                            }
                            m_SimplePaneStringBuilder.Append(MemoryProfilerModule.GetSimpleMemoryPaneText(data, ProfilerWindow, false));
                        }

                        if (m_SimplePaneStringBuilder.Length > 0)
                        {
                            UIElementsHelper.SetVisibility(m_UIState.Text, true);
                            m_UIState.Text.value = m_SimplePaneStringBuilder.ToString();
                        }
                        else
                        {
                            UIElementsHelper.SetVisibility(m_UIState.Text, false);
                        }
                    }
                }
            }