示例#1
0
            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);
                }
            }
示例#2
0
            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);
                }
            }
示例#3
0
        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);
                }
            }
        }
示例#4
0
        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);
            //    }
            //}
        }
示例#5
0
        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);
                }
            }
        }
示例#6
0
            public void Rearm(DefaultResourceLeak newLeak)
            {
                DefaultResourceLeak oldLeak = Interlocked.Exchange(ref this.leak, newLeak);

                oldLeak.CloseFinal();
            }
示例#7
0
 public GCNotice(DefaultResourceLeak leak)
 {
     this.leak = leak;
 }
示例#8
0
 public GCNotice(DefaultResourceLeak leak, object referent)
 {
     this.leak     = leak;
     this.referent = referent;
 }