Note that there are some explanatory texts on larger screens.

plurals
  1. PODoes the first MapActivity instance always leak?
    primarykey
    data
    text
    <p>While investigating memory issues in our application, it turns out that if the application Activity is a MapActivity, the first instance of it won't be finalized. Leading to other memory leak such as the view passed to setContentView.</p> <p>Does anyone notice that before?</p> <p>Here is the testing code showing that "MainActivity : 1" is not finalized whereas it is if MainActivity inherits from Activity.</p> <p>To test, one needs to change device or emulator orientation many times.</p> <pre><code> import com.google.android.maps.MapActivity; import android.app.Activity; import android.os.Bundle; import android.util.Log; public class MainActivity extends MapActivity { private static final String defaultTag = "MA"; private static final boolean isDebugModeActivate = true; private static final boolean isClassTagDisplayed = false; private static final boolean isWebModeActivate = false; static public void d(Object thiso, String message) { String tag = defaultTag + (isClassTagDisplayed == true ? "_" + thiso.getClass().getSimpleName() : ""); message = (isClassTagDisplayed == false ? thiso.getClass().getSimpleName() + " : " : "") + message; Log.d(tag, message); } public MainActivity() { counter++; uid++; id = uid; d(this, id + " tst constructor (" + counter + ")"); } private static int counter = 0; private static int uid = 0; private final int id; protected void finalize() throws Throwable { counter--; d(this, id + " tst finalize (" +counter + ") "); super.finalize(); } /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); } @Override protected boolean isRouteDisplayed() { return false; } } </code></pre> <p>Thank you, David</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload