1

i have a very simple app.

:: 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);
    }
}

}

My problem is that the app constantly consume more and more RAM. The APP starts with 14.80 MB and consumed after 10 minutes already 14.94 MB.

RAM Usage

Norwido
  • 51
  • 1
  • 7
  • It's normal for an app to expand a bit before reaching a steady state due to fragmentation of the various heaps. For a more detailed look at your app's memory usage, see http://stackoverflow.com/questions/2298208/how-do-i-discover-memory-usage-of-my-application-in-android . I'm not sure why you're singling SurfaceView out. – fadden Jul 24 '15 at 22:49

0 Answers0