Advanced techniques for concurrency & memory management (en)
summary
Claims concrete patterns from building Realm database and shows what actually works: using ReferenceQueue with PhantomReference to write near‑deterministic GC unit tests (keep a strong reference to the Reference object), avoiding finalizers, and pitfalls of WeakHashMap keys (strings, boxed ints, defensive copies). Presents working IPC alternatives: PendingIntent, Messenger, ResultReceiver and warns against EventBus/global state. Gives testable threading techniques: HandlerThread + CountDownLatch or IdleHandler/Executor tricks, and reusable coordination with Phaser as reusable barrier (onAdvance callback).
AI-written summary · about
chapters (17)
- 0:00Intro
- 0:17Realm
- 1:18WeakHashMap
- 4:54java.lang.ref.Reference
- 7:03ReferenceQueue
- 9:24Finalizer
- 11:05PhantomReference
- 17:06Write deterministic tests involving GC
- 17:51IdentityHashMap
- 21:131. Activity create a Handler
- 22:40EventBus
- 24:14Test Runner
- 30:32Looper & Unit test
- 30:46CountDownLatch
- 32:13CyclicBarrier
- 35:45Phaser
- 40:02Conclusion
related talks
44mCoordinating Space and Time
42mWorking Effectively with (Android) Legacy Code
31mEffective Procrastination
38mAdvanced Game Development Topics
40mBeyond Exceptions: Building Resilient Android Apps with S…
30mExtra! Extra! Thread all about it!
40mAndroid high performance baby
28mMy coroutines patterns and habits, 3 years later
