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 Original line Diff line number Diff line
@@ -678,16 +678,18 @@ public class Activity extends ContextThemeWrapper
    private Thread mUiThread;
    private Thread mUiThread;
    private final Handler mHandler = new Handler();
    private final Handler mHandler = new Handler();


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



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


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


    private static final String[] EMPTY_FILE_LIST = {};
    private static final String[] EMPTY_FILE_LIST = {};


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


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


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


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


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


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


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


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


        // Initialize the statics when this class is first instantiated. This is
        // Initialize the statics when this class is first instantiated. This is
        // done here instead of in the static block because Zygote does not
        // 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;
        mDensity = context.getResources().getDisplayMetrics().densityDpi;
    }
    }


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


    public static long getInstanceCount() {
    public static long getInstanceCount() {
        return sInstanceCount;
        return sInstanceCount;