Android SurfaceView Ram用法

时间:2015-07-24 19:05:28

标签: android render surfaceview ram

我有一个非常简单的应用程序。

:: Activity ::

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

    this.setContentView(new GameView(this));
}

:: GameView ::

public class GameView extends SurfaceView implements Runnable {

final private SurfaceHolder holder;

private boolean gameRunning;

public GameView(Context context) {
    super(context);
    holder = this.getHolder();

    gameRunning = true;

    ExecutorService executorService = Executors.newSingleThreadExecutor();
    executorService.execute(this);
    executorService.shutdown();
}

@Override
public void run() {
    Thread.currentThread().setName("GameRenderThread");

    while(gameRunning) {
        if(!holder.getSurface().isValid()) {
            continue;
        }

        Canvas canvas = holder.lockCanvas(null);
        canvas.drawColor(Color.WHITE);
        holder.unlockCanvasAndPost(canvas);
    }
}

}

我的问题是应用程序不断消耗越来越多的RAM。 APP以14.80 MB开始,10分钟后消耗14.94 MB。

RAM Usage

0 个答案:

没有答案