<com.seven.mym.widget.Menu_Bottom
android:id="@+id/menu_bottom"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center" >
</com.seven.mym.widget.Menu_Bottom>
이렇게 Menu_Bottom에다가 LinearLayout을 상속받아서 사용하고있거든요
근데 메모리가 계속 누적되는 형태가발생되는데 WeakReference를써서 GC호출도 해보고 null로해보고 다해봤는데도
메모리 해지가안되고 계속 1.5MB씩 쌓이다가 죽지는 않고 앱이 재실행(?)되버립니다.
재실행되면다시 10~15MB로복구합니다.
코드에다가는 Bitmap사용을 전혀안했구요 제가봤을땐 메모리해지가 안되서 그러는것같습니다.
코드는 파일첨부로 올리겠습니다.
메모리를 확인해봐야 알겠지만요....
대체로 static과 관련있을 확률이 높습니다. static으로 참조하는 객체가 직/간접적으로 Activity를 참조하고,
이로인한 Activity Leak이 발생하여 그 하위로 줄줄이 참조하는 View들이 단체로 Leak이 발생하는 경우가 있습니다.
Activity가 Leak이 발생하면 전체 뷰가 모두 Leak이 같이 발생하기 때문에 이팩트가 큽니다.
흠..static이라.. 확인해본결과 저는.. static과는 관련이없는거같습니다
View view = inflater.inflate(R.layout.menu_bottom, this, true); 에서
View를 재사용하지않고 계속 가져오는데 이부분에서 메모리 누수가 일어나는거같습니다.
이부분 재사용할수잇는 방법아시는분 ??
참고로
if(view = null) {
View view = inflater.inflate(R.layout.menu_bottom, this, true);
}
>>계속 null로 받아와요..
좀뻘쭘한 자답입니다
확인결과 View재사용과는 전혀별개인 폰트에서 메모리누수가일어나는군요..그래서 이렇게해결해주었습니다.
//전역변수
public static final String FONT_PATH = "fonts/InterparkGothicBold.ttf";
private static HashMap<String, Typeface> typefaceMap = new HashMap<String, Typeface>();
//메서드
public static Typeface getTypeface(Context context, String path) {
if ("DEFAULT".equals(path)) { return Typeface.DEFAULT; }
if (typefaceMap.get(path) != null) { return typefaceMap.get(path); }
Typeface typeface = Typeface.createFromAsset(context.getAssets(), path);
typefaceMap.put(path, typeface);
return typeface;
}




근데,.. 이렇게 상속해서 구현할 만한 이유가 별로 없을 것 같은데요..
그냥 xml 에서 만든 다음 activity 에서 구현해줘도 될 것 같은데요.