DrawAllocation 避免在draw和layout的时候创建对象,频繁的调用,垃圾回收操作会影响一些UI的体验
Avoid object allocations during draw/layout operations (preallocate and reuse instead)
Issue: Looks for memory allocations within drawing code
Id: DrawAllocation
You should avoid allocating objects during a drawing or layout operation. These are called frequently, so a smooth UI can be interrupted by garbage collection pauses caused by the object allocations.
The way this is generally handled is to allocate the needed objects up front and to reuse them for each drawing operation.
Some methods allocate memory on your behalf (such as Bitmap.create), and these should be handled in the same way.