I am trying to detect this memory leak.
I have two SurfaceViews, Aand B. I started A, then go to B, then click the back button to go back to A, and then go to again B.
I can see that my allocated memory is increasing every time I do this, and in the end I will get an error from memory.
This is how I navigate to B, from the inside SurfaceView, connected toA
Context context = this.getContext();
Intent i =new Intent(context, StartCareer.class);
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
context.startActivity(i);
In both views, I have many bitmap drawings. As BI can not find a reference to A, and the only reference outside of the context of which I can think of is a reference to a class Global, which I have. I also have some analytics that happen in the background. It could be a million different things, I would suggest that
I have a DDMS view on Eclipse, but I'm not sure what I'm looking for, or how to find an exact object that keeps repeating itself.
I would take either a course / course on the DDSM Allocation Tracker, or someone to indicate what I am doing wrong.
Additional Information:
I have several bitmaps drawn on SurfaceView. Examples of these Bare:
Bitmap rightB,leftB;
rightB = Bitmap.createScaledBitmap(BitmapFactory.decodeResource(getResources(), R.drawable.right), 100,75, true);
canvas.drawBitmap(rightB, rbX, rbY, null);
And my onDestroys
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (mThread.isAlive()){
mThread.setMenuRunning(false);
}
}
, MAT , , . Thread .
.
@Override
public void surfaceCreated(SurfaceHolder holder) {
loading=false;
if (!mThread.isAlive()){
mThread = new ViewThread(this);
mThread.setMenuRunning(true);
mThread.start();
}
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
if (mThread.isAlive()){
mThread.setMenuRunning(false);
}
}
, , , . , ?