哪些Android工具和方法最适合查找内存/资源泄漏?我已经开发了一个Android应用程序,我的手机应用程序开发的时候,一切看起来都很好,你想宣布胜利和出海,但你知道,那里必须有一些内存和资源泄漏;在Android上只有1600万b堆,而且它显然很容易在Android应用程序中泄漏。我一直在寻找,到目前为止,只能挖掘‘hprof’和‘traceview’的信息,没有得到很多好评。您遇到或开发了哪些工具或方法,并希望在OS项目中共享这些工具或方法?
3 回答
qq_花开花谢_0
TA贡献1835条经验 获得超7个赞
BaseAdapterImageViewGridViewunbindDrawables()
if (view instanceof ViewGroup && !(view instanceof AdapterView)) {
...}AdapterView
if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++)
unbindDrawables(viewGroup.getChildAt(i));
if (!(view instanceof AdapterView))
viewGroup.removeAllViews();}AdapterView
ImageView
if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
imageView.setImageBitmap(null);}unbindDrawables()
private void unbindDrawables(View view) {
if (view.getBackground() != null)
view.getBackground().setCallback(null);
if (view instanceof ImageView) {
ImageView imageView = (ImageView) view;
imageView.setImageBitmap(null);
} else if (view instanceof ViewGroup) {
ViewGroup viewGroup = (ViewGroup) view;
for (int i = 0; i < viewGroup.getChildCount(); i++)
unbindDrawables(viewGroup.getChildAt(i));
if (!(view instanceof AdapterView))
viewGroup.removeAllViews();
}}- 3 回答
- 0 关注
- 506 浏览
添加回答
举报
0/150
提交
取消
