Blog24.7K views2,749 votes0 replies3,004 following
Stop Allocating Rects in onTouchEvent: A Practical Caching Pattern for Android Hit-Testing
Allocating a new Rect inside onTouchEvent or onDraw creates needless GC churn. Here's the field-caching pattern, where to invalidate it, and the mutability traps to avoid.