This answer tells me that calling the recycle() method of a TypedArray allows for it to be garbage collected. My question is why TypedArray specifically needs a method for it to be garbage collected? Why can’t it just wait to be garbage collected like a regular object?
This answer tells me that calling the recycle() method of a TypedArray allows for
Share
This is required for caching purporse. When you call
recycleit means that this object can be reused from this point. InternallyTypedArraycontains few arrays so in order not to allocate memory each time whenTypedArrayis used it is cached inResourcesclass as static field. You can look atTypedArray.recycle()method code:So when you call
recycleyourTypedArrayobject is just returned back to cache.