public override string ToString() { System.Text.StringBuilder stringBuilder = StringUtility.AllocStringBuilder(); stringBuilder.Append($"ObjectPool<{typeof(T).FullName}> alloc {m_AllCount} objects. ") .Append($"{m_UsingCount} obejcts being used"); #if GF_DEBUG long currentTime = MDebug.GetMillisecondsSinceStartup(); for (int iObject = 0; iObject < m_Using.Count; iObject++) { UsingObject usingObject = m_Using[iObject]; float beUsedTime = (currentTime - usingObject.WhenBeUse) * 0.001f; stringBuilder.Append($"\nObject be used {beUsedTime:F2} seconds. ({usingObject.ToString()})"); } #endif return(StringUtility.ReleaseStringBuilder(stringBuilder)); }
public void CheckMemoryLeak() { long currentTime = MDebug.GetMillisecondsSinceStartup(); for (int iObject = 0; iObject < m_Using.Count; iObject++) { UsingObject usingObject = m_Using[iObject]; if (currentTime - usingObject.WhenBeUse > m_MemoryLeakMilliseconds) { MDebug.LogWarning("Pool" , $"Object in ObjectPool<{typeof(T).FullName}> be used {(currentTime - usingObject.WhenBeUse) * 0.001:F2} seconds ago, maybe memory leak!\n({usingObject.ToString()})"); } } }