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

烙印99
TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超13個(gè)贊
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)注
- 300 瀏覽
添加回答
舉報(bào)
0/150
提交
取消