private void _btnWeakCacheDetails_Click(object sender, System.EventArgs e) { HashSet hashSet = new HashSet(); int totalMemorySize = 0; CountedSet cacheEntries = new CountedSet(); foreach (IntHashTable.Entry entry in MyPalStorage.Storage.ResourceWeakCache) { WeakReference weakRef = (WeakReference)entry.Value; Resource res = (Resource)weakRef.Target; hashSet.Add(res.Id); cacheEntries.Add(res.Type); totalMemorySize += res.EstimateMemorySize(); } foreach (Resource res in MyPalStorage.Storage.ResourceCache) { if (res != null && !hashSet.Contains(res.Id)) { cacheEntries.Add(res.Type); totalMemorySize += res.EstimateMemorySize(); } } StringBuilder builder = new StringBuilder(); cacheEntries.SortByCount(); foreach (CountedSet.Entry de in cacheEntries) { builder.Append(de.Count + " - " + de.Value + "\n"); } builder.Append("Estimated memory size " + totalMemorySize / 1024 + "K"); _lblResourceWeakCacheDetails.Text = builder.ToString(); }