Layout Memory leak?

◇◆丶佛笑我妖孽 提交于 2019-12-11 05:55:52

问题


i am a junior android developer. For android UI design, i think most of android developer will use XML for layout design. Today, my senior developer said that he does not use XML for layout design. All UI design use code to generate. The reason he said is that the layout resource is not released by Android automatically.Using JNI release the layout resource . He does not tell you in detail because he think i am very junior.

I want to ask whether he is true or not. I have no idea for his point of view. But, i make sure that his code cannot reuse. Also, how the Android release the layout resource in its life cycle.

Thanks.


回答1:


The reason he said is that the layout resource is not released by Android automatically

The widgets created by inflating a layout resource are "released by Android automatically" when those widgets are removed from the activity or if the activity is destroyed. In other words, widgets are garbage-collected the same as any other Java object. And, this holds true no matter whether the widgets were created using layout resources or not.

It is conceivable that the parsed XML of the layout resource is cached by the process, so if the same layout is needed again, the parsing step can be skipped. This will not be very much memory. Avoiding XML layout resources to avoid such small memory caching is very short-sighted, not what I would expect from a true "senior developer".

Using JNI release the layout resource

JNI has nothing to do with layout resources. JNI has nothing to do with widgets, either.

He does not tell you in detail because he think i am very junior.

He is welcome to document his findings, providing proof for his claims and justifications for his decision.



来源:https://stackoverflow.com/questions/11562100/layout-memory-leak

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!