"Where did the memory leaks come from? In order to implement VectorDrawable inflation, the support library authors needed to update the way Context.getDrawable is implemented. But that function is final, so they had to make every View create a new copy of a Resources wrapper that could handle VectorDrawables. Besides being a large amount of work, this caused the various wrapped Resources to become out of sync, and to use a large amount of memory due to the duplication. If that function wasn’t final, that mess wouldn’t have happened."
Yup yup yup. Best practices are guidelines, not law.
Maybe it made sense at the time to make the function final to make it run a little bit faster ?
This is framework code where some aggressive optimizations can be justified.
It also made sense to limit what people could do with this function .. it was not intented to be hacked around.
Finally, it was not a memory leak but a big increase in memory useage.
It is kinda sad that we still have to support API < 21 phones and IMO that's the real issue here.
2 comments
[ 4.4 ms ] story [ 16.7 ms ] threadYup yup yup. Best practices are guidelines, not law.
Finally, it was not a memory leak but a big increase in memory useage.
It is kinda sad that we still have to support API < 21 phones and IMO that's the real issue here.