I have an Android app to be tested for Memory usage. As a test case, I need to increase its memory usage(RAM) programmatically. What are the possible ways? Does increasing thread.sleep time in my app would increase the memory usage?
1 Answer
ByteArrayInputStream bais = new ByteArrayInputStream(new byte[1000]);
Creates a object in your memory that is 1000 bytes.
1000000 bytes is about 1mb
4 Comments
Robin Dijkhof
It would add 1000bytes to your ram
Robin Dijkhof
That is because, as soon as the method ends, the memory is no longer needed and the garbage colector kicks in. Make it an attribute in your activity to keep it as long as the activity exists
Integer[] i = new Integer[Integer.MAX_VALUE];should do it.