Reputation: 2807
I need a test to be able to see if I can somehow use up the system's entire memory so that the system invokes the onLowMemory()
-event.
I need this to be able to test the behaviour of an application when the memory is running low. Any tips?
Upvotes: 3
Views: 994
Reputation: 36045
List<Integer> memoryHog = new ArrayList<Integer>();
while(true){
memoryHog.add(new Integer(5));
}
Would something as simple as that work? Basically loop and add objects until any memory allocated to your program gets used. Or are you looking for a way to literally use all the systems memory?
Upvotes: 1