michelle michelle - 2 years ago 136
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?

Answer Source
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?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download