Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RootTools create zombie process #15

Open
Loda opened this issue May 27, 2014 · 4 comments
Open

RootTools create zombie process #15

Loda opened this issue May 27, 2014 · 4 comments

Comments

@Loda
Copy link

Loda commented May 27, 2014

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
@Fusion
Copy link
Collaborator

Fusion commented Jun 11, 2014

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

@Loda
Copy link
Author

Loda commented Jun 12, 2014

@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,

@tomblenz
Copy link

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!

@M1cha
Copy link

M1cha commented Feb 14, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants