Comments (2)
Hi,
Do you have any more information than what's in this report's subject?
How did you observe a memory leak? Does your app run out of memory?
If you are referring specifically to the commands list, then is it actually leaking memory of not returning an amount of memory, but with an upper bound?
from rootshell.
I created an example
MainActivity.java
package com.example;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.AppCompatButton;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.stericson.RootShell.RootShell;
import com.stericson.RootShell.exceptions.RootDeniedException;
import com.stericson.RootShell.execution.Shell;
import java.io.IOException;
import java.util.concurrent.TimeoutException;
public class MainActivity extends AppCompatActivity {
static Shell shell;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (shell == null) {
try {
shell = RootShell.getShell(true);
} catch (IOException e) {
e.printStackTrace();
} catch (TimeoutException e) {
e.printStackTrace();
} catch (RootDeniedException e) {
e.printStackTrace();
}
}
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
AppCompatButton button = new AppCompatButton(this);
button.setText("test");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
getSupportFragmentManager().beginTransaction().replace(android.R.id.content, new TestFragment()).addToBackStack("").commit();
}
});
linearLayout.addView(button);
setContentView(linearLayout);
}
private Toast toast;
public void toast(String msg) {
if (toast != null) toast.cancel();
toast = Toast.makeText(this, msg, Toast.LENGTH_SHORT);
toast.show();
}
}
TestFragment.java
package com.example;
import android.graphics.Color;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.stericson.RootShell.execution.Command;
import java.io.IOException;
import java.util.Random;
public class TestFragment extends Fragment {
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = new View(getContext());
view.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
view.setBackgroundColor(Color.BLUE);
return view;
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
try {
MainActivity.shell.add(new Command(new Random().nextInt(), "ls /") {
@Override
public void commandOutput(int id, final String line) {
super.commandOutput(id, line);
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
((MainActivity) getActivity()).toast(line);
}
});
}
@Override
public void commandCompleted(int id, int exitcode) {
super.commandCompleted(id, exitcode);
getActivity().getSupportFragmentManager().popBackStack();
}
});
} catch (IOException e) {
e.printStackTrace();
}
}
}
from rootshell.
Related Issues (19)
- Conflicts in AndroidManifest.xml HOT 1
- Issue getting SanityCheckRootShell to work HOT 4
- Java As Root , executing a class - Not found error HOT 3
- What license agreement is this available under? HOT 1
- Gradle build fails at time of debugging with the RootShell present as aar
- Public commandWait? HOT 1
- java.lang.IllegalStateException - State:FLUSHED
- when calling findBinary() or exists() on a device where SuperSu is disabled - the thread is halted HOT 3
- RootShell.exists(file,isDir) running root way program termination
- RootShell throw ArrayIndexOutOfBoundsException when trying to get command output on Android Emulator API 14 and 23
- seems no implement of `RootShell.getCustomShell` HOT 6
- Holiday Wishes...
- Not working with Android Studio 3.3.1
- Proguard error - Need help with proguard configuration
- java.lang.NullPointerException
- RootShell.exists(filename) produces unexpected return value
- Support --mount-master option of SuperSU's su
- Does not work on Android 6 HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rootshell.