private void UpdateMemoryAnalysisGridForSelectedSymbol()
        {
            lock (this)
            {
                iStopPopulatingGrid = false;
            }
            //
            try
            {
                Cursor.Current = Cursors.WaitCursor;
                //
                if (iListView.SelectedIndices.Count > 0)
                {
                    MemObjStatisticalData data = iParser.Data;
                    int selectedIndex          = iListView.SelectedIndices[0];

                    ListViewItem selectedItem = iListView.SelectedItems[0];
                    if (selectedItem.Tag != null)
                    {
                        MemObjStatisticalCollection collection = (MemObjStatisticalCollection)selectedItem.Tag;
                        MemOpBase baseObject = collection[0];
                        System.Diagnostics.Debug.Assert(baseObject is MemOpAllocation);
                        MemOpAllocation memObj = (MemOpAllocation)baseObject;
                        //
                        string symbolText = "Unknown";
                        if (memObj.LinkRegisterSymbol != null && memObj.LinkRegisterSymbol.Symbol != null)
                        {
                            symbolText = memObj.LinkRegisterSymbol.Symbol.ToString();
                        }
                        iMemAnalysisDetailedInfoForSymbolGroupBox.Text = @"Detailed Analysis for Symbol '" + symbolText + @"'";
                        //
                        PopulateTableRows(collection);
                    }
                }
            }
            catch (Exception)
            {
                iGridIsDirty = false;
            }
            finally
            {
                Cursor.Current      = Cursors.Default;
                iStopPopulatingGrid = false;
                //iListView.Enabled = false;
                //iListView.Select();
            }

            lock (this)
            {
                iGridIsDirty = false;
            }
        }
        private void PrepareMemoryAnalysisData()
        {
            try
            {
                Cursor.Current    = Cursors.WaitCursor;
                iListView.Enabled = false;

                long totalAllocCount = 0;
                long totalFreeCount  = 0;
                long totalAllocSize  = 0;
                long totalFreeSize   = 0;
                long totalNetSize    = 0;

                // Ensure that each allocation-symbol is added to the symbol listbox
                MemObjStatisticalData data = iParser.Data;
                //
                iListView.BeginUpdate();
                int count = data.CollectionCount;
                for (int i = 0; i < count; i++)
                {
                    MemObjStatisticalCollection collection = data.CollectionAt(i);
                    if (collection.Count > 0)
                    {
                        System.Diagnostics.Debug.Assert(collection[0] is MemOpAllocation);
                        MemOpAllocation memObj = (MemOpAllocation)collection[0];
                        //
                        long allocCount   = collection.AllocationCount;
                        long freeCount    = collection.DeallocationCount;
                        long allocSize    = collection.TotalAmountOfAllocatedMemory;
                        long freeSize     = collection.TotalAmountOfDeallocatedMemory;
                        long netAllocSize = collection.TotalMemoryAllocatedButNotFreed;
                        //
                        ListViewItem item = new ListViewItem("");
                        item.Tag = collection;
                        item.SubItems.Add(allocCount.ToString());
                        item.SubItems.Add(freeCount.ToString());
                        item.SubItems.Add(allocSize.ToString());
                        item.SubItems.Add(freeSize.ToString());
                        item.SubItems.Add(netAllocSize.ToString());
                        string symbolText = "Unknown";
                        if (memObj.LinkRegisterSymbol != null && memObj.LinkRegisterSymbol.Symbol != null)
                        {
                            symbolText = memObj.LinkRegisterSymbol.Symbol.ToString();
                        }
                        item.SubItems.Add(symbolText);
                        iListView.Items.Add(item);

                        // Update totals
                        totalAllocCount += allocCount;
                        totalFreeCount  += freeCount;
                        totalAllocSize  += allocSize;
                        totalFreeSize   += freeSize;
                        totalNetSize    += netAllocSize;
                    }

                    if (count % 100 != 0)
                    {
                        Application.DoEvents();
                    }
                }
                iListView.EndUpdate();

                // Make the first item selected
                if (iListView.Items.Count > 0 && iListView.SelectedIndices.Count == 0)
                {
                    // Add total item
                    iListView.Items.Add(new ListViewItem(""));
                    //
                    ListViewItem totalItem = new ListViewItem("Totals:");
                    totalItem.SubItems.Add(totalAllocCount.ToString());
                    totalItem.SubItems.Add(totalFreeCount.ToString());
                    totalItem.SubItems.Add(totalAllocSize.ToString());
                    totalItem.SubItems.Add(totalFreeSize.ToString());
                    totalItem.SubItems.Add(totalNetSize.ToString());
                    totalItem.SubItems.Add("");
                    iListView.Items.Add(totalItem);
                    //
                    iListView.Items[0].Selected = true;
                    iListView.Select();
                }
            }
            finally
            {
                Cursor.Current    = Cursors.Default;
                iListView.Enabled = true;
                iListView.Select();
            }
        }