哪些Android工具和方法最適合查找內(nèi)存/資源泄漏?我已經(jīng)開發(fā)了一個Android應(yīng)用程序,我的手機應(yīng)用程序開發(fā)的時候,一切看起來都很好,你想宣布勝利和出海,但你知道,那里必須有一些內(nèi)存和資源泄漏;在Android上只有1600萬b堆,而且它顯然很容易在Android應(yīng)用程序中泄漏。我一直在尋找,到目前為止,只能挖掘‘hprof’和‘traceview’的信息,沒有得到很多好評。您遇到或開發(fā)了哪些工具或方法,并希望在OS項目中共享這些工具或方法?
3 回答

烙印99
TA貢獻1829條經(jīng)驗 獲得超13個贊
BaseAdapter
ImageView
GridView
unbindDrawables()
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 關(guān)注
- 297 瀏覽
添加回答
舉報
0/150
提交
取消