what is the use of recycle() method in TypedArray

前端 未结 4 1128
难免孤独
难免孤独 2020-12-14 14:32

I have created a GalleryView and ImageView which displays the Image bigger when an item is clicked in the gallery. I have used the below code to im

4条回答
  •  渐次进展
    2020-12-14 14:57

    The point is similar to the idea of clearing a pointer in a C-language (if you're familiar with that). It is used to make the data associated with a ready for garbage collection so memory/data is not inefficiently bound to a when it doesn't need to be. Read more here.

    It's important to note that this isn't really necessary unless you're actually reusing "a". GC should automatically clear up this data for you if the object is not used again. The reason why a TypedArray is different, however, is because a TypedArray has other internal data that must be returned (known as StyledAttributes) to the TypedArray for later reuse. Read about that here.

提交回复
热议问题