using System; using System.Collections; using System.Collections.Generic; #if GUM_DEBUG namespace Gum.Pooling.Diagnostics { internal static class PoolMonitor { public static readonly Dictionary UnreleasedPooledArrays = new Dictionary(); public static readonly Dictionary UnreleasedPooledLists = new Dictionary(); public static readonly Dictionary UnreleasedPooledDictionaries = new Dictionary(); static PoolMonitor() { AppDomain.CurrentDomain.ProcessExit += CheckLeakedPools; } private static void CheckLeakedPools(object _, EventArgs __) { foreach (string stackTrace in UnreleasedPooledArrays.Values) { #if UNITY_EDITOR UnityEngine.Debug.LogError($"ArrayPool not disposed correctly: {stackTrace}"); #else Console.WriteLine($"ArrayPool not disposed correctly: {stackTrace}"); #endif } foreach (string stackTrace in UnreleasedPooledLists.Values) { #if UNITY_EDITOR UnityEngine.Debug.LogError($"PooledList not disposed correctly: {stackTrace}"); #else Console.WriteLine($"PooledList not disposed correctly: {stackTrace}"); #endif } foreach (string stackTrace in UnreleasedPooledDictionaries.Values) { #if UNITY_EDITOR UnityEngine.Debug.LogError($"PooledDictionary not disposed correctly: {stackTrace}"); #else Console.WriteLine($"PooledDictionary not disposed correctly: {stackTrace}"); #endif } } } } #endif