Finalization Queue or F-Reachable Queue? SOSEX (Not So) New Commands

July 28, 2012

no comments

As Steve Johnson, the author of the awesome SOSEX debugging extension, pointed out in a comment on my last finalization post, as of SOSEX 4.0 you can use the !finq and !frq commands to inspect separately the finalization queue and the f-reachable queue.

As a reminder, objects on the finalization queue are objects that are eligible for finalization but are still referenced by the application. These are objects for which finalizers will run at some point, but the GC has not passed them over to the finalizer thread’s control. Objects on the f-reachable queue, on the other hand, are in the finalizer thread’s hands—they are queued up and waiting for the finalizer thread to run their finalizers.

Using the same example from the previous post, we can inspect the finalization queue with !finq and discover that there are only a few objects on the finalization queue:

0:003> !finq -stat
Generation 0:
       Count      Total Size   Type
         173            4152   MemoryLeak.Employee

173 objects, 4,152 bytes

Generation 1:
       Count      Total Size   Type
           2              48   MemoryLeak.Employee

2 objects, 48 bytes

Generation 2:
       Count      Total Size   Type
           1             104   System.Threading.Thread

1 objects, 104 bytes

However, there seem to be plenty of objects on the f-reachable queue, and their number grows over time, pointing towards a particular type of memory leak:

0:003> !frq -stat
Freachable Queue:
       Count      Total Size   Type
         463           11112   MemoryLeak.Employee

463 objects, 11,112 bytes

Of course, if you use the commands without the –stat switch they will print out the entire contents of the respective queue, enabling you to inspect the individual objects. For example:

0:003> !finq
Generation 0:
Address               Size   Type
0000000002e130c0        24   MemoryLeak.Employee
0000000002e15818        24   MemoryLeak.Employee
0000000002e17f70        24   MemoryLeak.Employee
0000000002e1a6c8        24   MemoryLeak.Employee
0000000002e1ce20        24   MemoryLeak.Employee
0000000002e1f578        24   MemoryLeak.Employee
…output snipped for brevity…

 I am posting short updates and links on Twitter as well as on this blog. You can follow me: @goldshtn

Add comment
facebook linkedin twitter email

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>