Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/339.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Android应用程序使用的内存比它应该使用的要多_Java_Android_Memory - Fatal编程技术网

Java Android应用程序使用的内存比它应该使用的要多

Java Android应用程序使用的内存比它应该使用的要多,java,android,memory,Java,Android,Memory,我目前正在开发一个应用程序,但内存一直有问题。我们的启动屏幕只有一个背景和一个按钮,通常使用160 MB内存。对于它正在做的事情来说,这肯定太过分了 这一趋势在我的整个应用程序中持续 我已经包括了XML和java代码。我还研究了内存的分配。几乎所有的记忆都被三件事占据。准确地说,有三份报告。我不知道这是什么意思 package com.example.tonymurchison.illuminandus; import android.content.Intent; import androi

我目前正在开发一个应用程序,但内存一直有问题。我们的启动屏幕只有一个背景和一个按钮,通常使用160 MB内存。对于它正在做的事情来说,这肯定太过分了

这一趋势在我的整个应用程序中持续

我已经包括了XML和java代码。我还研究了内存的分配。几乎所有的记忆都被三件事占据。准确地说,有三份报告。我不知道这是什么意思

package com.example.tonymurchison.illuminandus;

import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.view.WindowManager;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.ImageView;


public class MainActivity extends AppCompatActivity {

private ImageView startButton;
private ImageView fadeView;

@Override
protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    getSupportActionBar().hide();


    startButton = (ImageView) findViewById(R.id.start_button);

}

public void startButtonClick(View v){
    //TODO create animation
    Intent intent = new Intent(MainActivity.this,LevelSelect.class);
    startActivity(intent);
    finish();

}

private void animateIn(ImageView image) {
    Animation fadein = new AlphaAnimation(0.f, 1.f);
    fadein.setDuration(500);
    final View viewToAnimate = image;
    fadein.setAnimationListener(new Animation.AnimationListener(){

        @Override
        public void onAnimationStart(Animation animation){}

        @Override
        public void onAnimationRepeat(Animation animation){}

        @Override
        public void onAnimationEnd(Animation animation){
            Intent intent = new Intent(MainActivity.this,LevelSelect.class);
            startActivity(intent);
        }
    });
    image.startAnimation(fadein);
}

}
xml:



One列出了很多java.nio.ByteArrayBuffer内容。第二个是很多org.apache.harmony.dalvik.ddmc.Chunk的东西。第三个是很多java.lang.Integer的东西。
@drawable/titlescreen\u background
@drawable/start\u button
的物理大小分别是1.14MB和33kb
titlescreen\u background
的可能重复太大了。减小图像大小或尝试此操作。我建议你第一个。
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="0dp"
    android:paddingLeft="0dp"
    android:paddingRight="0dp"
    android:paddingTop="0dp"
    tools:context="com.example.tonymurchison.illuminandus.MainActivity"
    android:background="@drawable/titlescreen_background">

    <ImageView
        android:layout_width="300dp"
        android:layout_height="wrap_content"
        android:id="@+id/start_button"
        android:layout_centerHorizontal="true"
        android:layout_centerVertical="true"
        android:src="@drawable/start_button"
        android:onClick="startButtonClick"/>


</RelativeLayout>