nolanlawson / fuite

A tool for finding memory leaks in web apps
Apache License 2.0
3.95k stars 69 forks source link

Show retainer chain #9

Open nolanlawson opened 2 years ago

nolanlawson commented 2 years ago

The "count the objects" technique is usually pretty good at finding the "head vampire" (root of the retainer chain), but it's not always perfect. fuite could potentially show the actual retainer chain for these objects.

My only hesitation about this is that I feel like it devolves into reimplementing the Chrome DevTools, in particular the UI for diffing heap snapshots, whereas I already have instructions where you can diff your own heap snapshots in --debug mode.

nolanlawson commented 2 years ago

I don't think it would be possible to rely on the retainer chain, for a few reasons:

  1. We'd have to figure out how to ignore weak references
  2. We've have to identify circular references too

Even though it's dumb, I kind of like the iterations approach because it also helps filter out temporary caches. E.g. if you have a LRU cache of size 5, then 7 iterations will not surface that.