RootTools icon indicating copy to clipboard operation
RootTools copied to clipboard

RootTools create zombie process

Open Loda opened this issue 10 years ago • 4 comments

config : RootTools 3.4 on GT-S5830i android 2.3.6.

I assume this is related to http://bugs.java.com/view_bug.do?bug_id=6474073

Code:

@Override
public void onResume() {
    super.onResume();
    d("onResume");
    assertDeviceDontHaveRoot();
}

protected void assertDeviceDontHaveRoot(){
    final BaseActivity context = this;
    d("assertDeviceDontHaveRoot");
    Runnable runnable =  new Runnable() {
        @Override
        public void run() {
            final boolean  gotRoot = RootTools.isRootAvailable() || RootTools.isBusyboxAvailable() || RootTools.isAccessGiven();

            if (!gotRoot) {
                return;
            }

            Runnable forceCloseBecauseIsRoot = new Runnable() {
                @Override
                public void run() {
                        Utils.Dialog.show(....., new DialogInterface.OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialog) {
                                BaseActivity.this.finish();
                            }
                        });
                }// END run 
            }; // END forceCloseBecauseIsRoot

            context.runOnUiThread(forceCloseBecauseIsRoot);

        }//END run
    }; // END runnable

    context.runOnSecondaryThread(runnable);
}

after a few run:

adb shell ps

 app_67    2848  1     147600 15096 ffffffff 00000000 S com.example.app
 app_67    2961  1     151116 16120 ffffffff 00000000 S com.example.app
 app_67    3173  1     153052 16796 ffffffff 00000000 S com.example.app
 app_67    3237  1     153052 16796 ffffffff 00000000 S com.example.app
 app_67    3253  1     153052 16796 ffffffff 00000000 S com.example.app
 app_67    3462  1     158708 17544 ffffffff 00000000 S com.example.app
 app_67    3480  1     158300 17628 ffffffff 00000000 S com.example.app
 app_67    3494  1     162432 17664 ffffffff 00000000 S com.example.app
 app_67    3627  1     170720 18256 ffffffff 00000000 S com.example.app
 app_67    3659  1     174816 18652 ffffffff 00000000 S com.example.app
 app_67    3691  1     173840 18568 ffffffff 00000000 S com.example.app

Loda avatar May 27 '14 08:05 Loda

What does your code do, other than checking for root? The snippet you attached is not very informative.

Fusion avatar Jun 11 '14 09:06 Fusion

@Fusion

The purpose of that snippet is to check for Root without freezing the UI (from a secondary thread) on Activity.OnResume. If the device got Root, I finish() the current activity.

The problem is that every check RootTools.isXxxx() create a few Zombie (process that are not terminate until a device reboot) Thoses Zombie use all the RAM memory of the device until the point when the device completly stop being responsive.

regards,

Loda avatar Jun 12 '14 14:06 Loda

This issue has also been raised before on stackoverflow: http://stackoverflow.com/a/15485210/692167

Every time "su" is executed, it spawns a zombie process that survives the application and grows in memory allocation. Ouch!

tomblenz avatar Aug 14 '14 03:08 tomblenz

the solution is simple yet powerful: start your own custom su daemon :) this way you only need to show the root confirmation dialog once every reboot and you can keep a list of pid's in memory which you can retrieve even when your app process got killed by a task manager:

https://github.com/efidroid/android_system_extras_su/commits/master

M1cha avatar Feb 14 '16 16:02 M1cha