Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 82fe5642 authored by Carl Shapiro's avatar Carl Shapiro
Browse files

Comment out the finalize() methods defined on the Activity,

ContextImpl, View and ViewRoot classes.  This allows instances of
subclasses to be collected without the additional latency of
finalization.
parent 4bb79db4
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -678,16 +678,18 @@ public class Activity extends ContextThemeWrapper
    private Thread mUiThread;
    private final Handler mHandler = new Handler();

    // Used for debug only
    /*
    public Activity() {
        ++sInstanceCount;
    }


    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        --sInstanceCount;
    }
    */

    public static long getInstanceCount() {
        return sInstanceCount;
+5 −1
Original line number Diff line number Diff line
@@ -209,11 +209,14 @@ class ContextImpl extends Context {

    private static final String[] EMPTY_FILE_LIST = {};

    // For debug only
    /*
    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        --sInstanceCount;
    }
    */

    public static long getInstanceCount() {
        return sInstanceCount;
@@ -1446,7 +1449,8 @@ class ContextImpl extends Context {
    }

    ContextImpl() {
        ++sInstanceCount;
        // For debug only
        //++sInstanceCount;
        mOuterContext = this;
    }

+5 −1
Original line number Diff line number Diff line
@@ -1819,7 +1819,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
        mContext = context;
        mResources = context != null ? context.getResources() : null;
        mViewFlags = SOUND_EFFECTS_ENABLED | HAPTIC_FEEDBACK_ENABLED;
        ++sInstanceCount;
        // Used for debug only
        //++sInstanceCount;
        mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    }

@@ -2133,11 +2134,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, Accessibility
    View() {
    }

    // Used for debug only
    /*
    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        --sInstanceCount;
    }
    */

    /**
     * <p>
+5 −1
Original line number Diff line number Diff line
@@ -230,7 +230,8 @@ public final class ViewRoot extends Handler implements ViewParent,
            lt = new LatencyTimer(100, 1000);
        }

        ++sInstanceCount;
        // For debug only
        //++sInstanceCount;

        // Initialize the statics when this class is first instantiated. This is
        // done here instead of in the static block because Zygote does not
@@ -258,11 +259,14 @@ public final class ViewRoot extends Handler implements ViewParent,
        mDensity = context.getResources().getDisplayMetrics().densityDpi;
    }

    // For debug only
    /*
    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        --sInstanceCount;
    }
    */

    public static long getInstanceCount() {
        return sInstanceCount;