Blockquote
Large server applications often experience two problems with these by default. One of them is a slow start, since the initial heap is small and needs to be changed across many major collections. A more pressing issue is that the default maximum heap size is unreasonably small for most server applications.
Blockquote
You can start your program using the command line using these parameters java -Xms64m -Xmx256m chat_program. Here Xms64m = 64 MB of the initial heap size and Xmx256m = maximum heap size of 256 MB
source share