My program executes system commands, and returns the output line by line, however, there are a couple of commands that produces lots of lines, in this case the RAM usage rises to ~700Mbs, knowing that the usual RAM usage in any other commands is 50-60Mbs.
This is the method that handles reading the output using BufferedReader, it is called by another method that handles the creation of the process of the command. it also passes the output line by line to showOutputLine() method, which will print it to the console or to a TextArea.
protected void formatStream(InputStream inputStream, boolean isError) {
bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
String tempLine = null;
// Read output
try {
while ((tempLine = bufferedReader.readLine()) != null) {
showOutputLine(tempLine, isError);
}
} catch (IOException e) {// just stop
}
}
one example of the commands that causes the issue:
adb logcat
EDIT: it appears BufferedReader is innocent, however, the problem still persists. caused by JTextArea.