In this mini-Fragment episode, Kaushik talks about the process of Garbage collection and how it compares to Reference counting (which is the equivalent process in iOS).
How does each work? What are the differences? Which is better 😁 ? Listen on for all the juicy details…
Garbage collection (Android)
- Garbage collection [wikipedia.org]
- How GC works in Dalvik [medium.com]
- How GC works with circular references [stackoverflow.com]
Reference counting (iOS)
- Reference counting [wikipedia.org]
- An in-depth look at manual memory management in Objective C [tomdalling.com]
- Memory management in Objective C [rypress.com]
- Weak, strong, unowned, oh my! (references in Swift) [krakendev.io]
Kaushik Gopal: I was talking to one of my colleagues who works on our iOS applications the other day. We started off the conversation talking about advantages and disadvantages of the different local database options—like Realm and SQLite.
Then he mentioned something that blew my mind. A parent-child relationship is a typical use case in any marginally complex system, and we were talking about how to model them in a local database. Then he said, “Yeah, you’ve got to be extra careful with those relationships. You don’t want retain cycles.” This sounded a lot like a memory leak to me, so I probed a bit further, and that led me to the idea behind this mini-Fragment episode: the world of garbage collection and reference counting.