public bool UnArm(DefaultResourceLeak leak, ResourceLeakDetector owner, object referent) { lock (this.leakList) { if (this.owner is null) { //Already disposed return(false); } Debug.Assert(owner == this.owner); Debug.Assert(referent == this.referent); bool res = this.leakList.Remove(leak); if (0u >= (uint)this.leakList.Count) { // The close is called by byte buffer release, in this case // we suppress the GCNotice finalize to prevent false positive // report where the byte buffer instance gets reused by thread // local cache and the existing GCNotice finalizer still holds // the same byte buffer instance. GC.SuppressFinalize(this); // Don't inline the variable, anything inside Debug.Assert() // will be stripped out in Release builds bool removed = this.owner.gcNotificationMap.Remove(this.referent); Debug.Assert(removed); //this.referent = null; this.owner = null; } return(res); } }
public bool Arm(DefaultResourceLeak leak, ResourceLeakDetector owner, object referent) { lock (this.leakList) { if (this.owner is null) { //Already disposed return(false); } Debug.Assert(owner == this.owner); Debug.Assert(referent == this.referent); _ = this.leakList.AddLast(leak); return(true); } }
void ReportLeak(DefaultResourceLeak resourceLeak) { string records = resourceLeak.ToString(); if (this.reportedLeaks.TryAdd(records, true)) { if (records.Length == 0) { this.ReportUntracedLeak(this.resourceType); } else { this.ReportTracedLeak(this.resourceType, records); } } }
void ReportLeak(DefaultResourceLeak resourceLeak) { //if (!Logger.ErrorEnabled) { resourceLeak.Dispose(); return; } //string records = resourceLeak.Dump(); //if (this.reportedLeaks.TryAdd(records, true)) //{ // if (records.Length == 0) // { // this.ReportUntracedLeak(this.resourceType); // } // else // { // this.ReportTracedLeak(this.resourceType, records); // } //} }
void ReportLeak(DefaultResourceLeak resourceLeak) { if (!Logger.ErrorEnabled) { resourceLeak.Dispose(); return; } string records = resourceLeak.Dump(); if (this.reportedLeaks.TryAdd(records, true)) { if (0u >= (uint)records.Length) { this.ReportUntracedLeak(this.resourceType); } else { this.ReportTracedLeak(this.resourceType, records); } } }
public void Rearm(DefaultResourceLeak newLeak) { DefaultResourceLeak oldLeak = Interlocked.Exchange(ref this.leak, newLeak); oldLeak.CloseFinal(); }
public GCNotice(DefaultResourceLeak leak) { this.leak = leak; }
public GCNotice(DefaultResourceLeak leak, object referent) { this.leak = leak; this.referent = referent; }