michelle michelle - 9 months ago 61
Java Question

onLowMemory event testing

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


I need this to be able to test the behaviour of an application when the memory is running low.
Any tips?

List<Integer> memoryHog = new ArrayList<Integer>();
   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?