I will start by saying I am very new to android and also fairly new to java so I apologize for missing anything that seems blatantly obvious to others.
My code which is shown below is supposed to read a line from a file in the assets folder as long as the next line isn't empty, assign the contents of this line to a variable (The 'stringBuffer' String
), and then add this variable to an ArrayList
.
String stringBuffer = "";
BufferedReader reader = null;
ArrayList<String> fileLines = new ArrayList<>();
input = mContext.getAssets().open("Nodes.txt");
reader = new BufferedReader(new InputStreamReader(input));
while((stringBuffer = reader.readLine()) != null) {
fileLines.add(stringBuffer);
}
reader.close();`
I'm running the application on my phone, and when this process should take place the application just goes black, with LogCat showing "GC_FOR_ALLOC freed" followed by differing numbers.
I tried commenting out the fileLines.add(stringBuffer);
line and the program worked again, which is why I'm assuming that whatever is going wrong is due to this line.
I would like to know what this GC_FOR_ALLOC
means and also why it is happening. If any other information is needed please feel free to ask.
EDIT: This is in a non activity class is that matters.