안녕하십니까..
소스안에 finish 또는 break 를 걸어도, 메모리 상에서는 해제가 되지 않는 것 같습니다..
onDestory 등으로 죽일려고해도.. 도통 어떻게 값을 받아와야 하는 지를 모르겠습니다..
recycle 를 시도 해 보려고 해도.. 제가 리니어 타입으로 4~5조각을 하나로 뭉쳐놨는데..
여러개의 jpg 는 어떻게 불러와야 하는 지도 모르겠습니다..
죄송하지만.. 죄송한건 정말 압니다만..
소스 수정을 간곡히 부탁드립니다..
28시간이 넘게 컴퓨터만 하고있습니다.. 책을 5권을 뒤져도 도저히 모르겠어요....
public class ana3 extends Activity implements OnClickListener {
LinearLayout mainLayout;
ImageView imageView;
@Override
public void onCreate(Bundle savedInstanceState) {
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow().setFlags(Window.FEATURE_NO_TITLE, Window.FEATURE_NO_TITLE);
super.onCreate(savedInstanceState);
setContentView(R.layout.ana3);
Button btn1 = (Button)findViewById(R.id.btn1);
btn1.setOnClickListener(this);
Button btn2 = (Button)findViewById(R.id.btn2);
btn2.setOnClickListener(this);
Drawable(findViewById(R.id.mainLayout));
}
@Override
protected void onStart() {
System.gc();
super.onStart();
}
@Override
protected void onStop() {
finish();
System.gc();
super.onStop();
}
@Override
protected void onResume() {
finish();
System.gc();
super.onResume();
}
@Override
protected void onDestroy() {
finish();
System.gc();
super.onDestroy();
}
@Override
protected void onPause() {
finish();
System.gc();
super.onPause();
}
private void Drawable(View view) {
if (view.getBackground() != null) {
view.getBackground().setCallback(null);
}
}
public void onClick(View v){
switch (v.getId()) {
case R.id.btn1:{
Intent intent=new Intent(ana3.this,ana4.class);
startActivity(intent);
break;
}
case R.id.btn2:{
Intent intent=new Intent(ana3.this,ana2.class);
startActivity(intent);
break;
}}
}
public static boolean recycleBitmap(ImageView iv) {
if (iv != null) {
try {
Drawable d = iv.getDrawable();
iv.setImageBitmap(null);
if (d instanceof BitmapDrawable) {
Bitmap b = ((BitmapDrawable) d).getBitmap();
b.recycle();
}
d.setCallback(null);
}
catch (Exception e) {
e.getStackTrace();
return false;
}
return true;
}
return false;
}
}
================xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:orientation="vertical"
android:id="@+id/mainLayout">
<ImageView
android:id="@+id/image1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:src="@drawable/a41"
android:adjustViewBounds="true" />
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:orientation="horizontal"
android:id="@+id/mainLayout">
<Button
android:id="@+id/btn2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/b52btn"
android:adjustViewBounds="true"
android:layout_weight="1" />
<Button
android:id="@+id/btn1"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/b53btn"
android:adjustViewBounds="true"
android:layout_weight="1" />
</LinearLayout>
<ImageView
android:id="@+id/image3"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:adjustViewBounds="true"
android:src="@drawable/a44" />
</LinearLayout>
</ScrollView>
자바로 코딩하는기본 개념도 못잡고 계신데 이걸 넘겨도 개발이 쉽지않을겁니다
비트맵은 다루는 자체에도 메모리누수 버그가 있어요 간단한문제가 아니며 책이 아니고 외국싸이트 뒤지면 관련내용이 많이 있습니다
소스를 많이 잘라서 붙이셨나요;;
일단 finish()코드들은 이상한데 들어가있는것 같다는것만 빼면
올리신 그대로만 보면, 메모리 누수는 없을것 같은데요.
BitmapFactory를 쓰는것도 아니고, 이미지 가져오는 것도 drawable resource 사용하고 있고.. (이건 bitmap recycle하면 오류날텐데요?)
보이는 대로라면.. 이상하게 붙은것 같아 보이는(?) finish() 코드들 처리하시고;
onDestroy 에서
mainLayout = null;
imageView = null;
정도 추가만 해주시면;;?




쫌 휴식을 취한 다음에 해보세요..
무조건 붙어서 한다 해서 풀리는게 코딩이면..대한민국 예비군은 죄다 코딩신입니다...