@@ -6,7 +6,6 @@ namespace DotNetty.Common
66 using System ;
77 using System . Collections . Concurrent ;
88 using System . Collections . Generic ;
9- using System . Diagnostics ;
109 using System . Diagnostics . Contracts ;
1110 using System . Runtime . CompilerServices ;
1211 using System . Text ;
@@ -210,7 +209,7 @@ public DefaultResourceLeak(ResourceLeakDetector owner, object referent)
210209 DetectionLevel level = Level ;
211210 if ( level >= DetectionLevel . Advanced )
212211 {
213- this . creationRecord = NewRecord ( null , 3 ) ;
212+ this . creationRecord = NewRecord ( null ) ;
214213 }
215214 else
216215 {
@@ -226,15 +225,15 @@ public DefaultResourceLeak(ResourceLeakDetector owner, object referent)
226225 }
227226 }
228227
229- public void Record ( ) => this . RecordInternal ( null , 3 ) ;
228+ public void Record ( ) => this . RecordInternal ( null ) ;
230229
231- public void Record ( object hint ) => this . RecordInternal ( hint , 3 ) ;
230+ public void Record ( object hint ) => this . RecordInternal ( hint ) ;
232231
233- void RecordInternal ( object hint , int recordsToSkip )
232+ void RecordInternal ( object hint )
234233 {
235234 if ( this . creationRecord != null )
236235 {
237- string value = NewRecord ( hint , recordsToSkip ) ;
236+ string value = NewRecord ( hint ) ;
238237
239238 lock ( this . lastRecords )
240239 {
@@ -310,15 +309,7 @@ public override string ToString()
310309 }
311310 }
312311
313- static readonly string [ ] StackTraceElementExclusions =
314- {
315- "DotNetty.Common.Utilities.ReferenceCountUtil.Touch(" ,
316- "DotNetty.Buffers.AdvancedLeakAwareByteBuf.Touch(" ,
317- "DotNetty.Buffers.AbstractByteBufAllocator.ToLeakAwareBuffer(" ,
318- "DotNetty.Buffers.AdvancedLeakAwareByteBuf.RecordLeakNonRefCountingOperation("
319- } ;
320-
321- static string NewRecord ( object hint , int recordsToSkip )
312+ static string NewRecord ( object hint )
322313 {
323314 Contract . Ensures ( Contract . Result < string > ( ) != null ) ;
324315
@@ -342,39 +333,7 @@ static string NewRecord(object hint, int recordsToSkip)
342333 }
343334
344335 // Append the stack trace.
345- StackFrame [ ] array = new StackTrace ( ) . GetFrames ( ) ;
346- if ( array != null )
347- {
348- foreach ( StackFrame e in array )
349- {
350- if ( recordsToSkip > 0 )
351- {
352- recordsToSkip -- ;
353- }
354- else
355- {
356- string estr = e . ToString ( ) ;
357-
358- // Strip the noisy stack trace elements.
359- bool excluded = false ;
360- foreach ( string exclusion in StackTraceElementExclusions )
361- {
362- if ( estr . StartsWith ( exclusion , StringComparison . InvariantCulture ) )
363- {
364- excluded = true ;
365- break ;
366- }
367- }
368-
369- if ( ! excluded )
370- {
371- buf . Append ( '\t ' ) ;
372- buf . Append ( estr ) ;
373- buf . Append ( StringUtil . Newline ) ;
374- }
375- }
376- }
377- }
336+ buf . Append ( Environment . StackTrace ) ;
378337
379338 return buf . ToString ( ) ;
380339 }
0 commit comments