-2

I am looking for a code which will deliberately crash my Tomcat Server.


EDIT (moved from comments)
I did this but it still doesnot crash

ArrayList list = new ArrayList(); 
for (int i = 0; i < Integer.MAX_VALUE; i++) 
{ list.add(new Object()); } 

I have tried static Lists, HashMaps but I am still not able to cause java.lang.OutOfMemoryError: Java heap space

Thanks

Chains
  • 12,541
  • 8
  • 45
  • 62

1 Answers1

0

Better than dealing with the code itself, reduce the maximum heap size.

Look for -Xmx on your tomcat bin directory and replace whatever value it has with -XmxXXXm where XXX is how many MB will the heap be allowed to get.

perencia
  • 1,498
  • 3
  • 11
  • 19