3 ms·
Doesn't Android have a tracing garbage collector? How do retain cycles cause leaks?
by School-Cotton 2y ago
Doesn't Android have a tracing garbage collector? How do retain cycles cause leaks?
- refulgentis 2y ago_Really_ handwaving here, tl;dr in a pure cycle scenario its resolved but it seemed it didn't help much compared to the number of footguns available. ex. felt like on iOS you'd cover 90% of cases by just "just do [weak self] in every dispatch_async" In Android you have to remember that, and there's this god-object called Context that you use to retrieve strings, images, and layouts (~XIBs). Each Activity (ViewController) has one and its incredibly easy to accidentally retain it, and thus the whole screen. The standard way of handling button presses / whatever IBActions are now also would cause it, and these heavily used things called BroadcastReceivers would usually be spun up when an Activity was started, and instantly form a cycle with the Activity that for some reason can't be noticed easily. Sorry for the handwaving, it's been very strange spending so much calendar time working on something I had to understand a lot less. (tl;dr: solo founder that shipped a point of sale system to 2,000 restaurants starting on iPad 1.0, had to get to 0 leaks all by myself. versus the warm safe blanket of bigco). This Medium article is an excellent overview I used to remind myself, though the AI art is incredibly shitty, enough to make me wonder if the article is plagirized. https://medium.com/@naeem0313/top-10-android-memory-leak-causes-and-how-to-avoid-them-b7ea67e716b6 https://medium.com/@naeem0313/top-10-android-memory-leak-cau...
- School-Cotton 2y agoMakes sense!