Profile picture
, 14 tweets, 3 min read Read on Twitter
Hey Googlers, free idea for AOSP to get rid of leaks once and for all:

Implement lifecycle awareness into the GC. 🤯

Here's how it'd work (thread):
There would be a new Java API that's just a method that takes an Object. We could pass anything to it. Similar to LeakCanary, we would pass an activity instance after onDestroy, a fragment, etc
On the next pass, the GC looks at all these objects and figure out if it can finalize them and if not why not. It builds a shortest path to GC roots live, ignoring weak refs etc. It can do that because, well, it's the GC
Then there's another API where you can listen to those objects that couldn't be GCed and it gives you that path to gc roots and tells you which refs are likely causing the issue.
As a developer, I could send that to my leak backend, and the default could upload to the play store.
By the way, those "Shortest Paths to GC Roots"? They're called "leaktraces". I invented this word, please credit me on Wikipedia 😘
Once you got that, you first turn it on for AOSP stock apps on your internal builds and you fix the hundreds of leaks that are still, today, right now, lurking in AOSP
Then you add CTS tests that fail if there is a single leak detected. Of course, you give a free pass to Samsung, they'll need 5 years to fix them all. But surfacing those leaks will help shaming and move the needle.
From that, your Android engs will learn a ton about leaks and the tools & framework teams will figure out trap patterns and add better lint checks
Then Android apps will be able to run much longer, at much lower footprint, lower battery usage, and the planet will burn ever so slightly slower ♻️
Alternative paths:

1) flutter fairy land where everything is magic and memory is infinite because reasons
2) kills apps even more often, see
I am told I didn't invent the word leaktrace, which makes sense since I've never quite invented anything. Here's prior usage: metacpan.org/release/ANDYA/…
The ideas in this thread are the result of a long chat with @jessewilson so you can thank / blame him if you think it's crazy. He's magical like that 🙏
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to Py ⚔
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!