Skip to content

Instantly share code, notes, and snippets.

@Rangor
Created December 7, 2016 08:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rangor/ba014dae4bf97b287897d526902d5cbd to your computer and use it in GitHub Desktop.
Save Rangor/ba014dae4bf97b287897d526902d5cbd to your computer and use it in GitHub Desktop.
Android memory testing
public class MemoryTesterActivity extends AppCompatActivity {
List<String> memoryHog;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_memory_tester);
memoryHog = new ArrayList<>();
for(double i = 0; i < 1000000; i++){
String number = Double.toString(i);
memoryHog.add(number);
}
}
public void asynctaskexecute(View target){
new MyAsyncTask().execute();
}
private class MyAsyncTask extends AsyncTask {
@Override
protected Object doInBackground(Object[] params) {
return doSomeStuff();
}
private Object doSomeStuff() {
//do something to get result
return new Object();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment